开发者

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

开发者 https://www.devze.com 2022-12-30 15:21 出处:网络
I have ListViewActivity public class SelectActivity extends ListActivity { protected void onCreate(Bundle savedInstanceState) {

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

精彩评论

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