Note that there are some explanatory texts on larger screens.

plurals
  1. POChanging backgroundcolor for Relativelayout in setviewbinder
    primarykey
    data
    text
    <p>I am new to android,in my app i want to change the color of my custom listview. Here is my code</p> <pre><code>String[] from = new String[] { Contactsnew.CONTENT}; int[] to = new int[] { R.id.content123, R.id.linear123}; custAdapter = new SimpleCursorAdapter(this, R.layout.activity_contactitem, null, from, to); //ListView listView = (ListView) findViewById(R.id.listv); listview.setAdapter(custAdapter); custAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder(){ @Override public boolean setViewValue(View view, Cursor cursor, int col) { // TODO Auto-generated method stub Log.d("asda", "asd"); if(view.getId() == R.id.linear123){ RelativeLayout relative = (RelativeLayout)view.findViewById(R.id.linear123); relative.setBackgroundColor(0xFFC1E7F); return true; } return false; } }); </code></pre> <p>After running its showing a ArrayIndexoutofbounds.</p> <p>Log report</p> <pre><code>08-13 12:44:57.004: E/AndroidRuntime(2107): FATAL EXCEPTION: main 08-13 12:44:57.004: E/AndroidRuntime(2107): java.lang.ArrayIndexOutOfBoundsException 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.support.v4.widget.SimpleCursorAdapter.bindView(SimpleCursorAdapter.java:131) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.support.v4.widget.CursorAdapter.getView(CursorAdapter.java:256) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.AbsListView.obtainView(AbsListView.java:1315) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.ListView.makeAndAddView(ListView.java:1727) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.ListView.fillDown(ListView.java:652) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.ListView.fillFromTop(ListView.java:709) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.ListView.layoutChildren(ListView.java:1566) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.AbsListView.onLayout(AbsListView.java:1147) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.view.View.layout(View.java:7035) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.LinearLayout.onLayout(LinearLayout.java:1042) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.view.View.layout(View.java:7035) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.ScrollView.onLayout(ScrollView.java:1205) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.view.View.layout(View.java:7035) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.view.View.layout(View.java:7035) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.widget.FrameLayout.onLayout(FrameLayout.java:333) 08-13 12:44:57.004: E/AndroidRuntime(2107): at android.view.View.layout(View.java:7035) 08-13 12:44:57.004: E/AndroidRuntime(2107): at </code></pre> <p>Like this i am getting.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload