我有一个具有ExpandableList的android应用程序,在其适配器中getChildView(int,int,boolean,View,ViewGroup)
如果某些条件为真,我想重绘ExpandableList,我该怎么办?
答案 0 :(得分:0)
以下是答案,但建议不:
这是你的能力:
public class MyActivity extends Activity implements MyAdapterListener{
private ExpandableListView expandableListView1;
private MyAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
expandableListView1 = (ExpandableListView) findViewById(R.id.expandableListView1);
adapter = new MyAdapter(this);
expandableListView1.setAdapter(adapter);
}
@Override
public void doRefresh() {
adapter.notifyDataSetChanged();
}
}
这是你的适配器:
public class MyAdapter extends BaseExpandableListAdapter{
public interface MyAdapterListener{
public void doRefresh();
}
private MyAdapterListener listener;
public MyAdapter(MyAdapterListener listener){
this.listener = listener;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
if(some condition is true and you want to refresh the list view){
listener.doRefresh();
}
return null;
}
}
希望这有帮助。