ListView without scroll on Android -
i want set listview show items without scroll.
below layout:
<linearlayout android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:id="@+id/tv1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="large text" android:textcolor="@android:color/black" android:textappearance="?android:attr/textappearancelarge" /> <listview android:id="@+id/list" android:layout_width="match_parent" android:layout_height="wrap_content" > </listview> <textview android:id="@+id/tv2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="large text" android:textcolor="@android:color/black" android:textappearance="?android:attr/textappearancelarge" /> </linearlayout>
the linearlayout belong scrollview.
want set listview items , scroll parent's scroll.
how can it?
this how should set listview in scrollview, else answered, should never put listview in scrollview, if listview contain lot of items
listview lv = (listview)findviewbyid(r.id.list); // listview inside scrollview lv.setontouchlistener(new listview.ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { int action = event.getaction(); switch (action) { case motionevent.action_down: // disallow scrollview intercept touch events. v.getparent().requestdisallowintercepttouchevent(true); break; case motionevent.action_up: // allow scrollview intercept touch events. v.getparent().requestdisallowintercepttouchevent(false); break; } // handle listview touch events. v.ontouchevent(event); return true; } });
Comments
Post a Comment