开发者

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(savedInsta开发者_如何学PythonnceState);
        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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜