小编Nya*_*nLH的帖子

带有Checkbox的Android ExpandableListView,控制已检查状态

朋友们,

我正在尝试编写一个在ExpandableListView中使用复选框的应用程序,我在这里遇到了一个问题,即维护应用程序的复选框状态,我从这里得到了示例,我的问题是保持复选框的检查状态,每当我检查其中一个复选框和展开列表,复选框没有它们应该具有的已检查状态.我试图通过添加ArrayList来存储商店的位置并在getChildView()中重新加载位置,但仍然没有达到我想要的目的.这是我的代码

public class ElistCBox extends ExpandableListActivity {

    private static final String LOG_TAG = "ElistCBox";
    ArrayList<String > chkState = new ArrayList<String>();
    static final String colors[] = {"grey","blue","yellow","red"};
    static final String shades[][] ={ { "lightgrey","#D3D3D3","dimgray","#696969", "sgi >gray 92","#EAEAEA"},
        { "dodgerblue 2","#1C86EE","steelblue >2","#5CACEE","powderblue","#B0E0E6"},
        { "yellow 1","#FFFF00", "gold 1","#FFD700","darkgoldenrod 1"," #FFB90F" },
        {"indianred 1","#FF6A6A", "firebrick 1","#FF3030", "maroon","#800000" } };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.main); 
        SimpleExpandableListAdapter expListAdapter = new SimpleExpandableListAdapter( …
Run Code Online (Sandbox Code Playgroud)

checkbox android expandablelistview

10
推荐指数
1
解决办法
3万
查看次数

标签 统计

android ×1

checkbox ×1

expandablelistview ×1