Android setting LinearLayout background programmatically

后端 未结 6 871
一整个雨季
一整个雨季 2021-02-06 02:34

I have a situation where I need to set a background on a LinearLayout programatically.

In my layout, I am setting my background using `android:background=\"?android:att

6条回答
  •  囚心锁ツ
    2021-02-06 03:25

    It's a bad idea doing it the way the accepted answer tells you to. The problem is that you also need to call the list's onItemCheckedStateChanged to update what's needed (the action bar title for example).

    In that case all you need to do is simply call getListView().setItemChecked(position, true); when the item is checked and getListView().setItemChecked(position, false); when it's not checked.

提交回复
热议问题