Reputation: 2790
I am using recyclerViewAdapter to fill recycler view. Inside each recyclerItem must be list with items, and I decided to make it listView.
so inside onBindViewHolder of recyclerView i create new cursor, make new query (with help of contentResolver) and than i need to fill my listView with this data.
here is some my code:
Cursor.moveToFirst();
int size = Cursor.getCount();
if (size > 0){
for (int i = 0; i<size; i++){
Cursor.moveToPosition(i);
setCurrentItem();
}
}
private void setCurrentItem(){
View View = LayoutInflater.from(mContext).inflate(R.layout.list_item_test, null);
mLogo = (ImageView)cardView.findViewById(R.id.iv_Item_logo);
mName = (TextView)cardView.findViewById(R.id.tv_cardItem_Name);
mNumber = (TextView)cardView.findViewById(R.id.tv_cardItem_Number);
mBlocked = (TextView)cardView.findViewById(R.id.tv_Item_blocked);
mDate = (TextView)cardView.findViewById(R.id.tv_Item_Date);
String Name = Cursor.getString(AccountsFragment.NAME);
String Numb = Cursor.getString(AccountsFragment.NUMBER);
Numb = USB_Converter.Numbers(Numb);
String Date = Cursor.getString(AccountsFragment.DATE);
Date = USB_Converter.friendlyDate(Date);
int Status = Cursor.getInt(AccountsFragment.STATUS);
if (Status == UserAccountsEntry.STATUS_ID_ACTIVE){
mBlocked.setVisibility(View.VISIBLE);
} else {
mBlocked.setVisibility(View.GONE);
}
mName.setText(Name);
mNumber.setText(Numb);
mDate.setText(Date);
mHolder.mListView.addFooterView(cardView);
}
this works without any errors, but it's does not show listView...
any idea how to fix this?
EDIT listView.xml:
<ListView
android:id="@+id/lv_accountList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
/>
Upvotes: 1
Views: 3214
Reputation: 30088
You don't show the content of list_item_test.xml, but you'll probably need to give the inner ListView an absolute height in dp (or give it's parent an absolute height and then use match_parent
on the ListView).
You can't use wrap_content
for a ListView (it will shrink to 0 height), and you can't use match_parent
if the parent doesn't have an independently derived or explicitly declared height.
Upvotes: 2