باسلام و عرض خسته نباشید
من در رابطه با ExpandableListView یک کدی نوشتم ولی برای یکی از خط های کدم ارور زیر را می دهد :
ListAdapter is abstract; cannot be instantiated
و کدهایم :(قسمتی که ارور دارد را مشخص کردم)
public class MainActivity extends ExpandableListActivity {
List<String> ChildList;
Map<String, List<String>> ParentListItems;
ExpandableListView expandablelistView;
// Assign Parent list items here.
List<String> ParentList = new ArrayList<String>();
{ ParentList.add("ANDROID");
ParentList.add("PHP");
}
// Assign children list element using string array.
String[] AndroidName = { "ANDROID STUDIO","ANDROID EXAMPLES","ANDROID TUTORIALS" };
String[] PhpName = { "XAMPP","PHPMYADMIN","MYSQL" };
String[] ByDefalutMessage = {"Items Loading"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ParentListItems = new LinkedHashMap<String, List<String>>();
for ( String HoldItem : ParentList) {
if (HoldItem.equals("ANDROID")) {
loadChild(AndroidName);
} else if (HoldItem.equals("PHP"))
loadChild(PhpName);
else
loadChild(ByDefalutMessage);
ParentListItems.put(HoldItem, ChildList);
}
expandablelistView = (ExpandableListView) findViewById(R.id.expandableListView1);
// ************************************************************************
// ارور مربوط به این خط است
final ExpandableListAdapter expListAdapter = new ListAdapter(this, ParentList, ParentListItems);
// *****************************************************************************
expandablelistView.setAdapter(expListAdapter);
expandablelistView.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
final String selected = (String) expListAdapter.getChild(
groupPosition, childPosition);
// Switch case to open selected child element activity on child element selection.
Intent intent;
switch(selected){
case "ANDROID STUDIO":
intent = new Intent(MainActivity.this, i_1.class);
startActivity(intent);
break;
case "ANDROID EXAMPLES":
intent = new Intent(MainActivity.this, i_1.class);
startActivity(intent);
break;
case "ANDROID TUTORIALS":
intent = new Intent(MainActivity.this, i_1.class);
startActivity(intent);
break;
case "XAMPP":
intent = new Intent(MainActivity.this, i_1.class);
startActivity(intent);
break;
case "PHPMYADMIN":
intent = new Intent(MainActivity.this, i_1.class);
startActivity(intent);
break;
case "MYSQL":
intent = new Intent(MainActivity.this, i_1.class);
startActivity(intent);
break;
}
return true;
}
});
}
private void loadChild(String[] ParentElementsName) {
ChildList = new ArrayList<String>();
for (String model : ParentElementsName)
ChildList.add(model);
}
}
ممنون می شوم راهنایی ام کنید که چه گونه این ارور را برطرف کنم
پاسخ ها