How to inflate view when user click on listView item?
I'm building a listView of clients, which needs to display extra information when the user touches one item on the list.
I want something like this:
How to inflate the information panel when user select one client? I'm looking for someth开发者_高级运维ing similar to the android keyboard.
If that bottom box with the extra info needs to be exactly like on the sketches, then I'd use something like this:
Layout:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ListView android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<LinearLayout android:id="@+id/InfoBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="gone">
... Stuff ...
</LinearLayout>
</RelativeLayout>
Toggle the visiblity of the InfoBox element here (gone/visible), and update the stuff inside it - a bunch of TextViews I guess.
I would not even inflate that when the user clicks on a list entry.
Just inflate it in onCreate() and add it as a custom layer above your ListView (to float above it) via addContentView(). After that, set its visibility to View.INVISIBLE. When the user clicks on a list item, you can populate the views inside that overlay with the correct information and set its visibility to View.VISIBLE. This way you dont have to inflate your layout all the time.
精彩评论