SimpleExpandableListAdapter

SimpleExpandableListAdapter

我尝试将源代码从android 2传递到android4。该代码不会提示我错误,并且应用程序启动。但是开始时有一个登录名。当我单击“登录”时,应用程序崩溃。日志消息显示SimpleExpandableListAdapter存在问题。这是使用SimpleExpandableListAdapter的代码的一部分:

expListAdapter = new SimpleExpandableListAdapter(_ContactScreen_object,
                _groupSections, // groupData describes the first-level entries
                R.layout.group_row, // Layout for the first-level entries
                new String[] { "sectionName" }, // Key in the groupData maps to
                // display
                new int[] { R.id.groupname }, // Data under "friendName" key
                // goes into this TextView
                _result, // childData describes second-level entries
                R.layout.child_row, // Layout for second-level entries
                new String[] { "friendName", "status" }, // Keys in childData
                // maps to display
                new int[] { R.id.childname, R.id.rgb } // Data under the keys
        // above go into these
        // TextViews
        )


日志猫:



您是否认为问题在于代码太旧了? SimpleExpandableListAdapter的结构现在不同了吗?我要改变什么?

最佳答案

Context参数_ContactScreen_objectnull。这是SimpleExpandableListAdapter.java的第210行:

mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);


您的代码需要更多上下文才能提供进一步的帮助。

关于java - Android应用程序中的SimpleExpandableListAdapter问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18569025/

10-09 03:46