0

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

Nikhil PV
  • 1,014
  • 2
  • 16
  • 29
  • 1
    Possible duplicate of [Android: requestLayout() improperly called](http://stackoverflow.com/questions/24598977/android-requestlayout-improperly-called) – danypata Aug 25 '16 at 09:23
  • @danypata i have tried all those solutions but not working. – Nikhil PV Aug 25 '16 at 09:25
  • Can you post the ```R.layout.row_pass_name1``` and how you use the adapter in your code. – danypata Aug 25 '16 at 09:28
  • Are you sure you're looking at the right `Adapter` code? I mean, do you have more than one `ListView` in your setup? The log says it's the `lvItemName` `ListView` causing the problem, but you've posted the layout element for `lv`. – Mike M. Aug 25 '16 at 09:36
  • @Mike lvItemName is another listview. – Nikhil PV Aug 25 '16 at 09:41
  • Right. That's the one causing the problem. - `requestLayout() improperly called by android.widget.ListView{42062af8 VFED.VC. ......I. 0,42-250,82 #7f0c0007 app:id/lvItemName}` – Mike M. Aug 25 '16 at 09:43
  • it is also same – Nikhil PV Aug 25 '16 at 09:44
  • OK. I'm asking if the `getView()` method you've posted is from the `Adapter` you're using for `lvItemName`. – Mike M. Aug 25 '16 at 09:45
  • same adapter only.. – Nikhil PV Aug 25 '16 at 09:47
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/121821/discussion-between-balaji-and-mike-m). – Nikhil PV Aug 25 '16 at 09:47
  • That's all I was asking. If it's the same `Adapter` code, then I'm not sure what your problem is. – Mike M. Aug 25 '16 at 09:51

0 Answers0