listview in xml
<ListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fastScrollEnabled="false"
android:choiceMode="singleChoice" />
adapter code
@Override
public View getView(final int position, View v, ViewGroup parent) {
LayoutInflater li1 = getLayoutInflater();//(LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (v == null)
v = li1.inflate(R.layout.row_pass_name1, parent,false);
TextView etNO = (TextView) v.findViewById(R.id.etBillNo);
final CheckBox chkDelete = (CheckBox) v.findViewById(R.id.chkDelete);
etNO.setText(items.get(position).billNo);
chkDelete.setChecked((items.get(position).deleteCheckBox)
.equals("1") ? true : false);
v.setBackgroundColor(getResources().getColor(
position % 2 != 0 ? R.color.brown_light_background
: R.color.white));
return v;
}
When i am calling the adapter class it is giving me exception as
W/View(12240): requestLayout() improperly called by android.widget.ListView{420751e8 VFED.VC. ........ 0,42-1266,161 #7f0c0013 app:id/lv} during second layout pass: posting in next frame W/View(12240): requestLayout() improperly called by android.widget.ListView{42062af8 VFED.VC. ......I. 0,42-250,82 #7f0c0007 app:id/lvItemName} during layout: running second layout pass
row_pass_name1 xml layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:gravity="center_vertical"
android:minHeight="40dp"
android:orientation="horizontal" >
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/gray_lighter" />
<CheckBox
android:id="@+id/chkDelete"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:ems="5"
android:singleLine="true"
/>
<!-- <View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/gray_lighter" /> -->
<TextView
android:id="@+id/tvSeqNo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".5"
android:ems="5"
android:gravity="center"
android:padding="5dp"
android:singleLine="true"
android:textSize="@dimen/font_default"
/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/gray_lighter" />
<TextView
android:id="@+id/etBillNo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:ems="14"
android:gravity="left|center"
android:padding="5dp"
android:singleLine="true"
android:textSize="@dimen/font_default"
/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@color/gray_lighter" />
</LinearLayout>
I have tried solutions available on net but not working. Please help me fix this issue and thanks in advance