I have created a ExpandableList View with some group items and corresponding child items.
I’m able to get to the child view, and access the child view properties with the help of groupPosition and childPosition.
Now I have to put two ImageButton on this every child view, and trigger different Intents on click of each one.
I tried to code to set the onClickListeners for each Image Button and get the corresponding results, but I’m facing difficulty in the return value, where the getChildView returns only one View.
How can I get the response for each ImageButton ‘s click?
My code is below:
public View getChildView (final int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent)
{
final View providbtn = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);
final View lecvidbtn = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);
final ImageButton providbtn1 = (ImageButton)providbtn.findViewById(R.id.provid);
final ImageButton lecvidbtn1 = (ImageButton)lecvidbtn.findViewById(R.id.lecvid);
//final View childItemClicked = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);
//final ImageButton ib = (ImageButton)childItemClicked.findViewById(R.id.)
//ImageButton provid = (ImageButton)findViewById(R.id.provid);
providbtn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplication(), "Topic Proc video is: "+topic[groupPosition]+" and Chapter is "+chapter[groupPosition][childPosition], Toast.LENGTH_LONG).show();
flag = "p";
Bundle bundle = new Bundle();
bundle.putString("topic",topic[groupPosition] );
bundle.putString("chapter",chapter[groupPosition][childPosition] );
Intent goHome = new Intent(getApplicationContext(), VideoWeb.class);
goHome.putExtras(bundle);
startActivity(goHome);
}
});
lecvidbtn1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
Toast.makeText(getApplication(), "Topic Lec video is: "+topic[groupPosition]+" and Chapter is "+chapter[groupPosition][childPosition], Toast.LENGTH_LONG).show();
flag = "l";
Bundle bundle = new Bundle();
bundle.putString("topic",topic[groupPosition] );
bundle.putString("chapter",chapter[groupPosition][childPosition] );
Intent goHome = new Intent(getApplicationContext(), VideoWeb.class);
goHome.putExtras(bundle);
startActivity(goHome);
}
});
return lecvidbtn; //My confusion is here. How to capture the return value for any of the image buttons clicked above.?
}
try this way
and child_row.xml