简体   繁体   中英

Listview with Listview as an items, the inner listview is not fully visible

I am trying to have a listview with listviews as items, only the first row is visible in the inner listview(listview item).

My listview Item xml is :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/main_bg" >
    <ListView
        android:id="@+id/numbers_list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:cacheColorHint="@null"
        android:divider="@null" >
    </ListView>
</RelativeLayout>

You can't have scrollable view in other scrollable views . The same happens if you put a list view in a ScrollView .
For your purpose, why not implement multiple view items type? Examples here or here .

inside of one scrollable view another won't scroll.. call this method after u set adapter and pass your listview..

private void setListViewHeight(ListView listView) {
ListAdapter listAdapter = listView.getAdapter();
int totalHeight = 0;
for (int i = 0; i < listAdapter.getCount(); i++) {
View listItem = listAdapter.getView(i, null, listView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}

ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (listAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}

http://kirukkupayal-mani.blogspot.in/2012/11/android-expandable-listview-inside.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM