2015-06-03 78 views
-1

我正在與tutorial一起工作ExpandableListViewExpandableListAdapter - 無法實例化類型ExpandableListAdapter

MainActivity.java部,有在

listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);線錯誤。

我更改了我的ExpandableListAdapter.java類名,但MainActivity仍然存在錯誤。

下面的代碼:

public class MainActivity extends Activity { 

ExpandableListAdapter listAdapter; 
ExpandableListView expListView; 
List<String> listDataHeader; 
HashMap<String, List<String>> listDataChild; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 

    // get the listView 
    expListView = (ExpandableListView) findViewById(R.id.qlist_main); 

    // preparing list data 
    prepareListData(); 

    listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild); 

    // setting list adapter 
    expListView.setAdapter(listAdapter); 

我怎樣才能解決這個問題?

+0

發佈導致問題的代碼 – Blackbelt

回答

1

ExpandableListAdapter是一個接口,所以你不能實例化它。相反,創建自己的適配器來實現它。