次のコードは現在アクティビティで動作しています。しかし、フラグメントに使用したいのですが、試してみると、展開可能なリストが認識されません。誰かがこれで私を助けることができれば、大きな助けになるでしょう.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_expandable_list);
createGroupList();
createCollection();
expListView = (ExpandableListView) findViewById(R.id.my_exp_list);
final ExpandableListAdapter expListAdapter = new ExpandableListAdapter(
this, groupList, laptopCollection);
expListView.setAdapter(expListAdapter);
setGroupIndicatorToRight();
expListView.setOnChildClickListener(new OnChildClickListener() {
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
final String selected = (String) expListAdapter.getChild(
groupPosition, childPosition);
Toast.makeText(getBaseContext(), selected, Toast.LENGTH_LONG)
.show();
return true;
}
});
}
私のフラグメントoncreateViewで、
View v = inflater.inflate(R.layout.activity_expandable_list, container, false); createGroupList();
createCollection();
expListView = (ExpandableListView) inflater.inflate(R.id.my_exp_list, container, false);