0

i create a custom listview that contain 3 items

my question is how come when i used activity if you want to create custom listview you create 1st a layout for a single row and and inflate it inside other layout container

and when i used listfragment i dont need a parent layout container i just directly used only the single row layout and i dont have to use any parent of it

i need explaination of it, i have no problem running it but i need info how it runs without parent layout to put in single row layout of the listview because in activity you need to setContentView the parent layout but in listfragment how come i do it without a setcontentview and directly inflate only the single row layout of the list view

1 Answers1

1

If you use a ListFragment, ListFragment has a default layout that consists of a single, full-screen list in the center of the screen. You can have a custom layout but to do this, your own view MUST contain a ListView object with the id "@android:id/list" (or list if it's in code).

For the custom listview you have the listview and for each row in listview you inflate a custom layout. ListView is a view group that displays a list of scrollable items. So you have a custom adapter. In custom adapter getview you inflate your custom layout for rows in listview. you return the view. You set the Customadapter to listview. So listview has custom layout inflated for each row.

Also Listview recycles views. To know more check the below link's

How ListView's recycling mechanism works

http://developer.android.com/guide/topics/ui/layout/listview.html

http://developer.android.com/reference/android/app/ListActivity.html. Same for ListFragment

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256