2

Hi just wondering how I can make a listener or sorts. I wanna make it so when one of the childs are click it opens a YouTube video INSIDE the App, not as a Web actitivity....anyways the iportant part is not the youtube part, i just want to know how i can make each child open a different youtube link of its own.

To be clear, my question is: HOW can i make each child do something different, for example open a youtube link or EVEN open a new intent.

this is what i got so far.

public class Adobe extends Activity{

    ExpandableListAdapter listAdapter;
    ExpandableListView expListView;
    List<String> listDataHeader;
    HashMap<String, List<String>> listDataChild;
    String name;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.adobe);

     // get the list view
        expListView = (ExpandableListView) findViewById(R.id.lvExp);

        prepareListData();

        listAdapter = new ExpandableListAdapter(this, listDataHeader, listDataChild);

     // setting list adapter, show the list
        expListView.setAdapter(listAdapter);

        expListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
            @Override
            public boolean onChildClick(ExpandableListView parent, View v,
                    int groupPosition, int childPosition, long id) {


                            // This is just testing to see what i come up with
                name = v.getTag().toString();

                switch (childPosition) {
                case 0:
                    Toast.makeText(getBaseContext(), "Intro", Toast.LENGTH_LONG ).show();
                    break;

                default:
                    Toast.makeText(getBaseContext(), "" + childPosition, Toast.LENGTH_SHORT ).show();
                    break;
                }

                return false;
            }
        });
    }

PS. the child as set as Buttons instead of Textview in the XML file, but if i can do with Textview then ill will.

PSSS. the list is already made in another function, just didnt included here so it wasnt too long.

user1919840
  • 435
  • 1
  • 5
  • 11

1 Answers1

1

Did you make sure that your child items are not focusable? Do they contain views that can take focus? E.g. Button or EditTextView. If so your OnChildClickListener will not be called. See also

OnItemClickListener doesn't work with ListView item containing button

OnItemCLickLIstener doesn't work on ListView

ListView OnItemClickListener Not Responding?

Community
  • 1
  • 1
Lars Blumberg
  • 19,326
  • 11
  • 90
  • 127