创建Android的布局与来自服务器的响应按钮

创建Android的布局与来自服务器的响应按钮

本文介绍了创建Android的布局与来自服务器的响应按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查了一下周围,我决不能完全找到的东西,帮助我什么,我试图完成。在我的Andr​​oid应用我希望能够向服务器进行一些数据的请求时,返回的数据我想填充一个滚动视图,因为有太多适合在一个显示器。我这样做的原因是因为数据会经常更新,为我做应用程序(imaginee微博)的持续更新。我已经建立了XML的LinearLayout将填充滚动视图我只需要找到构建出观的最好方式。

I checked around and and I can never quite find something that helps me with what I am trying to accomplish. In my Android app I want to be able to make a request to the server for some data, when that data is returned I want to populate a scrollview because there is too much to fit in one display. The reason I am doing this is because the data will be updated too often for me to do continuous updates of the app (imaginee twitter). I've already built out the XML linearlayout which will populate the scroll view I just need to find the best way of building out the View.

我头脑风暴的一些方法而这可能是可能的,我伸手想这将是最实际的,如果可能的。

I've brainstormed a few methods which this could be possible and I'm reaching out for which would be most practical if possible.


  1. 传递数据作为XML饲料 - 我觉得这会让我通过所有从服务器喂食,并使用XML标记将数据内容并放入布局中的适当位置的数据运行。然后建立下一个布局,并从那里走。

  1. Passing the data as a XML feed - I feel this would allow me to run through all the data which is fed from the server and using the XML tags pull the content and place into the appropriate location in the layout. Then build the next layout and go from there.

从服务器传递的完整布局XML - 这可以建立布局,但我觉得会$ P $从制作上的布局的按钮,这将是我传递的​​所有数据被设置的onclick触发pvent我。我知道有匿名的听众可能做的工作,但我不能肯定我怎么能得到它在这种情况下触发。

Passing the full layout XML from the server - This could build the layout but I feel would prevent me from making the buttons on the layout which will trigger onclick from being setup as I am passing all the data. I know there are anonymous listeners which could do the job but I'm not quite sure how I could get it to trigger in this case.

我有一个第三,但它已经逃脱我在这个时候。任何帮助是AP preciated。

I had a third but it has escaped me at this time. Any help is appreciated.

推荐答案

对不起,这么长时间的这种反应,我一直忙于其他事情,不能code。那真是太好了,但只有当我建立了按钮,我一起去。由于我膨胀的布局,我需要通过选择这样选择pre现有按钮。

Sorry for taking so long on this response, I've been busy with other things and couldn't code. That was really good but only if I am building the button as I go along. Since I am inflating a layout I need to select a pre existing button by selecting it as such.

按钮thisbutton =(按钮)findViewById(R.id.buttonid);

Button thisbutton = (Button)findViewById(R.id.buttonid);

这之后,我可以打造出onclicklistener然后添加新的视图布局。谢谢虽然帮助!您的脚本指出在正确的方向,以确定哪些需要做!

After this I can build out the onclicklistener then add the new view to the layout. Thanks for the help though! Your script pointed in in the correct direction to identify what needed to be done.!

这篇关于创建Android的布局与来自服务器的响应按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 09:13