Multiple Listview Are Being Cut
im having an issue when i try to make a linearlayout with multiple listviews. originally when i added multiple custom linearlayouts containing a textview and a listview i could not
Solution 1:
Put your listViews in a vertical scroll. You can have scrollable listView inside of a vertical scroll by the following trick. use the following code and enjoy!
privateint listViewTouchAction;
/** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//...
setListViewScrollable(myListView1);
setListViewScrollable(myListView2);
}
privatevoidsetListViewScrollable(final ListView list) {
list.setOnTouchListener(newOnTouchListener() {
@OverridepublicbooleanonTouch(View v, MotionEvent event) {
listViewTouchAction = event.getAction();
if (listViewTouchAction == MotionEvent.ACTION_MOVE)
{
list.scrollBy(0, 1);
}
returnfalse;
}
});
list.setOnScrollListener(newOnScrollListener() {
@OverridepublicvoidonScrollStateChanged(AbsListView view,
int scrollState) {
}
@OverridepublicvoidonScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
if (listViewTouchAction == MotionEvent.ACTION_MOVE)
{
list.scrollBy(0, -1);
}
}
});
}
listViewTouchAction is a global integer value.
Solution 2:
It is not possible to have a ListView inside ScrollView (since the ListView is also a scrollable component) this is why your ListView is cropped to the screen.
If you need to display several List on screen to let user select something, you may use Spinner instead of List
Post a Comment for "Multiple Listview Are Being Cut"