davs
davs

Reputation: 9406

Android's listview. Update view within of of the cells just after invalidating Activity's view

I have ListViewActivity

public class SelectActivity extends ListActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.select_one_of);
        SimpleAdapter adapter = new SimpleAdapter(
            this,
            createChildList(),
            R.layout.select_one_of_childrow, 
            new String[] { KEY_VALUE },
            new int[] { R.id.selectoneof_add_new_item});
        setListAdapter(adapter);
    }
// ...
}

after setListAdapter() calls I would like to execute the following code:

((TextView) getListView().getChildAt(0).findViewById(R.id.selectoneof_add_new_item)).setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.ticked, 0);

but getListView().getChildAt(xxx) returns null and I catch NullPointerException. Where should I put mentioned above code-snippet?

Upvotes: 1

Views: 1141

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007584

Where should I put mentioned above code-snippet?

Nowhere. Instead, write a custom ListAdapter and customize your rows that way. Here is a free excerpt from one of my books that demonstrates the general technique.

Upvotes: 1

Related Questions