【发布时间】:2016-07-31 15:41:25
【问题描述】:
我有一个名为 ExpandableListAdapter 的类,它扩展了 BaseExpandableListAdapter。我的 getChildView 方法如下所示:
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
ViewGroup parent) {
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this.context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
}
tv_questionAmountResult = (TextView) convertView.findViewById(R.id.tv_questionAmountResult);
tv_correctAmountResult = (TextView) convertView.findViewById(R.id.tv_correctAmountResult);
tv_wrongAmountResult = (TextView) convertView.findViewById(R.id.tv_wrongAmountResult);
bt_allQuestions = (Button) convertView.findViewById(R.id.bt_allQuestions);
bt_correctQuestions = (Button) convertView.findViewById(R.id.bt_correctQuestions);
bt_wrongQuestions = (Button) convertView.findViewById(R.id.bt_wrongQuestions);
return convertView;
}
我的其他类 ActTraining 在 onCreate 方法中使用 ExpandableListAdapter:
ExpandableListAdapter listAdapter;
ExpandableListView expListView;
// get the listview
expListView = (ExpandableListView) findViewById(R.id.topicExpandableListView);
// preparing list data
prepareListData();
listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);
// setting list adapter
expListView.setAdapter(listAdapter);
现在我想为 3 个按钮添加 OnClickListener,但我不确定放置正确。 我是否必须在我的 getChildView 或我的 ActTraining 类中添加监听器?
【问题讨论】:
标签: android android-layout listview android-adapter