0

Here is my layout activity layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/transparent"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingTop="5dp">
        // There are lots of views in here
    </FrameLayout>

    <include layout="@layout/story_entry_children_listview"/>
</LinearLayout>

Here is the included layout:

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">

    <ListView
        android:id="@+id/story_entry_children_listview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</merge>

My list adapter is correct because If I apply on another ListView of another activity layout it's showing all elements are showing. Probably there might have a problem in this activity layout. Please help.

Here is my Adapter Class:

public class ChildEntryListAdapter extends BaseAdapter {

    private Context mContext;

    private ArrayList<StoryEntry> mListData;

    private LayoutInflater mLayoutInflater;

    public ChildEntryListAdapter(Context context, ArrayList<StoryEntry> listData) {
        mContext = context;
        mListData = listData;
        if(mListData == null) mListData = new ArrayList<>();
        mLayoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mListData.size();
    }

    @Override
    public Object getItem(int i) {
        return mListData.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        if (convertView == null) {
            convertView = (new StoryEntryChildView(mContext));
        }
        return convertView;
    }
}
iamcrypticcoder
  • 2,609
  • 4
  • 27
  • 50
  • What is the value returned in getCount() of the adapter? – Aman Gautam Jan 29 '15 at 18:17
  • 1
    You should be using `match_parent` or a fixed height for your `ListView` height – codeMagic Jan 29 '15 at 18:20
  • @Mooooooo I added adapter class for you and getCount() return correct value. – iamcrypticcoder Jan 29 '15 at 18:22
  • If your `FrameLayout` is taking up most of the room it could be all the elements are in there you just have to scroll to see them. – Chris Handy Jan 29 '15 at 18:32
  • @codeMagic Hi, Would you please explain why I have to use **match_parent** or **fixed_height** for ListView. You know **wrap_content** also work with ListView. BTW, **match_parent** or **fixed_height** are working in my case. – iamcrypticcoder Jan 29 '15 at 18:35
  • @mahbub.kuet I could try but I would rather let a former engineer on the Android UI explain it so here you go http://stackoverflow.com/questions/4270278/layout-width-of-a-listview and you also might want to watch the [World of ListView Google I/O](https://www.youtube.com/watch?v=wDBM6wVEO70&t=40m45s) from several years ago – codeMagic Jan 29 '15 at 18:38
  • `wrap_content` can work but is not recommended – codeMagic Jan 29 '15 at 18:40

0 Answers0