我已经在我的另一个android应用程序上做了这个,它运行得完美无缺,但是当我在另一个应用程序中这样做时,它就不工作了。
我一直收到一个错误:"ExpandableListAdapter不能解析为类型“
public class MainActivity extends Activity implements AdListener,
OnClickListener {
ExpandableListAdapter listAdap;
ExpandableListView expListView;
List<String> listDataHeader;
HashMap<String, List<String>> listDataChild;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Full Screen
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
// get the list view
expListView = (ExpandableListView) findViewById(R.id.lvExp);
prepareListData();
listAdap = new ExpandableListAdapter(this, listDataHeader, listDataChild);
// setting list adapter, show the list
expListView.setAdapter(listAdap);
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
public boolean onChildClick(ExpandableListView parent,
View v, int groupPosition, int childPosition,
long id) {
}
});
}发布于 2014-01-24 20:14:20
ExpandableListAdapter是一个接口,不能实例化。如果您需要更多的灵活性,则应该使用SimpleExpandableListAdapter或extends BaseExpandableListAdapter,并重写其方法。
https://stackoverflow.com/questions/21341600
复制相似问题