Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8474005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:30:21+00:00 2026-06-10T17:30:21+00:00

I have created a ExpandableList View with some group items and corresponding child items.

  • 0

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.?
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T17:30:23+00:00Added an answer on June 10, 2026 at 5:30 pm

    try this way

      public View getChildView(int groupPosition,int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
             View v = null;
              if( convertView != null )
                  v = convertView;
              else
                  v = inflater.inflate(R.layout.child_row, parent, false); 
              String c = (String)getChild( groupPosition, childPosition );
              final int grpPos = groupPosition;
              final int childPos = childPosition;
                  ImageButton button1 = (ImageButton)v.findViewById( R.id.imageButton1);
                  ImageButton button2 = (ImageButton)v.findViewById( R.id.imageButton2);
           // and set onClickListener to this two button
                  button1.setOnClickListener(new OnClickListener(){
                     @Override
                     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);
    
                     }
                  )};
                  button2.setOnClickListener(new OnClickListener(){
    
                       @Override
                       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 v;
    
          }
    

    and child_row.xml

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:background="#ebebeb"
    android:layout_height="50dp">
    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_marginLeft="22dp"
        android:src="@drawable/button1" />
    
    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_marginLeft="46dp"
        android:layout_toRightOf="@+id/imageButton1"
        android:src="@drawable/button2" />
    
     </RelativeLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created 3 classes as following Ext.mine.TextParent - Inherting from Textfield Ext.mine.child.TextChildA -
I have created some JQuery that will expand a div 'popup' on hover and
I have created a list. And I need to get the text on the
Overview: I have an Expandable List View which displays items of the type ToDoElement
I have seen some links which am not able to trace it out.I am
Have created a ATL COM project through which I am inserting Menu Items to
Have created a custom navigation menu in wordpress that has some pages and some
i have created a resource file Resource.resx in my project and added some values
I have created a WebView layout, which is used to access a specific website,
I've created an activity, which has an expandable list view of category, and some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.