开发者

listview reusable component - architecture - android

i have a complex view which contains 4 list views arranged as per the requirement. i have been been able to开发者_如何学运维 implement and get it working. but this is a sole activity and data needs to supplied internally (within the activity). i want to define a way where in, this complex view is like a reusable component which is called by other activities that provide data for all 4 list views and then the view shows up in the screen.

could somebody please guide me as to how do i go about achieving this functionality.


You should define your listview structure in a layout file of its own. Then you can use whats called inflation, which lets you "inject" seperate layout files into your main layout in run-time. Take a look at:

http://developer.android.com/reference/android/view/LayoutInflater.html

Take note at the introductory notes. Android is already inflating an XML resource, namely the layout file you´ve defined in setContentView(), you can grab the current instance of the inflater and use it as you see fit, saving greatly on memory as opposed to instantiating it yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜