Android BaseExpandableListAdapter和GetChildView-自定义对话框限制?
第一个问题和一个android新手-希望这意味着有一个简单的解决方案,我刚刚完全错过-这里希望。。。来吧 我使用一个自定义的BaseExpandableListAdapter来驱动一个ExpandableListView,在这个适配器中,我重写了GetChildView方法来显示一个带有5个按钮的自定义子级Android BaseExpandableListAdapter和GetChildView-自定义对话框限制?,android,events,expandablelistview,expandablelistadapter,customdialog,Android,Events,Expandablelistview,Expandablelistadapter,Customdialog,第一个问题和一个android新手-希望这意味着有一个简单的解决方案,我刚刚完全错过-这里希望。。。来吧 我使用一个自定义的BaseExpandableListAdapter来驱动一个ExpandableListView,在这个适配器中,我重写了GetChildView方法来显示一个带有5个按钮的自定义子级 public class ExpandableListAdapter extends BaseExpandableListAdapter { private Context con
public class ExpandableListAdapter extends BaseExpandableListAdapter {
private Context context;
private ArrayList<String> groups;
private ArrayList<ArrayList<String>> children;
private int setCount;
private int currentSetNumber;
...
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.child_layout, null);
parent.setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
}
Button bPlus = (Button) convertView.findViewById(R.id.btnAddSet);
if(childPosition == 0){
Button bSetPlace = (Button) convertView.findViewById(R.id.bSetPlace1);
bSetPlace.setText("Set 1");
bSetPlace.setOnClickListener(new View.OnClickListener(){
***public void onClick(View v) {
// TODO Auto-generated method stub
Intent myIntent = new Intent(context,WeightEntryDialog.class);
context.startActivity(myIntent);
}***
});
... remainder of method (not relevant)
我是否对BaseExpandableListAdapter类做得太过分了?如果我想在适配器中做一些我真的应该在其他地方做的事情,那么保持对可展开列表中的子项的控制对我来说很重要。希望我很清楚,有人可以提供一些指导。非常感谢。目前,我决定通过直接从适配器类扩展对话框来解决问题,而不是启动单独的活动,并且我创建了一个自定义侦听器,以便在对话框和适配器之间共享一些数据
public class WeightEntryDialog extends Activity {