请查看我的要求并提出解决方案。好的,这是我的要求,我有一个可扩展列表视图,其中包含一个组项目和一个包含按钮的子项目。单击子按钮,我要删除整个组。我该怎么办?
我的活动如下
public class TaskActivity extends AppCompatActivity {
ExpandableListView expandableListView;
ExpandableListViewAdapter expandableListViewAdapter;
List<String> Tasklist;
HashMap<String, List<String>> childitemslist;
Window window;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_task);
if(Build.VERSION.SDK_INT>=21){
window=this.getWindow();
window.setStatusBarColor(getColor(R.color.primaryTextColor));
}
Toolbar toolbar=findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Pending Tasks");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
expandableListView = findViewById(R.id.expandable_listview);
showList();
expandableListViewAdapter = new ExpandableListViewAdapter(TaskActivity.this, Tasklist, childitemslist);
expandableListView.setAdapter(expandableListViewAdapter);
}
private void showList() {
Tasklist = new ArrayList<String>();
childitemslist = new HashMap<String, List<String>>();
Tasklist.add("new task-1");
Tasklist.add("new task-2");
Tasklist.add("new task-3");
Tasklist.add("new task-4");
Tasklist.add("new task-5");
Tasklist.add("new task-6");
Tasklist.add("new task-7");
List<String> description1 = new ArrayList<String>();
description1.add("Description-1 should be done in this task before 29th should be done in this task before 29th should be done in this task before 29th");
List<String> description2 = new ArrayList<String>();
description2.add("Description-2");
List<String> description3 = new ArrayList<String>();
description3.add("Description-3");
List<String> description4 = new ArrayList<String>();
description4.add("Description-4");
List<String> description5 = new ArrayList<String>();
description5.add("Description-5");
List<String> description6 = new ArrayList<String>();
description6.add("Description-6");
List<String> description7 = new ArrayList<String>();
description7.add("Description-7");
childitemslist.put(Tasklist.get(0), description1);
childitemslist.put(Tasklist.get(1), description2);
childitemslist.put(Tasklist.get(2), description3);
childitemslist.put(Tasklist.get(3), description4);
childitemslist.put(Tasklist.get(4), description5);
childitemslist.put(Tasklist.get(5), description6);
childitemslist.put(Tasklist.get(6), description7);
}
@Override
public void onBackPressed() {
super.onBackPressed();
}
}