Reputation: 105
I am having a strange problem. I am unable to start a new activity from ExpandableListView OnChildClickListener. I can set and view the toast, but when I add intent the app stopped working.
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
Toast.makeText(getContext(), listDataHeader.get(groupPosition) + " : " + listDataChild.get(
listDataHeader.get(groupPosition)).get(childPosition) +" gp "
+ String.valueOf(groupPosition) +" cp "+String.valueOf(childPosition), Toast.LENGTH_SHORT).show();
/*Intent intent = new Intent(getActivity(), VerseActivity.class);
//intent.putExtra("verse_name", groupPosition);
//intent.putExtra("chapter_number",childPosition);
startActivity(intent);*/
return false;
}
});
Please help me solve this problem. I am using fragments.
Upvotes: 0
Views: 36
Reputation: 6632
try with the below thing. You need to return true
in the onChildClick
method.
expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
Toast.makeText(getContext(), listDataHeader.get(groupPosition) + " : " + listDataChild.get(
listDataHeader.get(groupPosition)).get(childPosition) +" gp "
+ String.valueOf(groupPosition) +" cp "+String.valueOf(childPosition), Toast.LENGTH_SHORT).show();
Intent intent = new Intent(getActivity(), VerseActivity.class);
intent.putExtra("verse_name", groupPosition);
intent.putExtra("chapter_number",childPosition);
startActivity(intent);
return true;
}
});
Upvotes: 1