2

How can i make a text clickable in Expandable list-view in Android studio. For example, when i click a text, it should open a webiste in my phone default browser. As you can see in the picture, under Afghanistan, there is Hope Academy Rwanda and website next to it. I want this webiste be clickable over Hope Academy Rwanda in the background. So when I click Hope Academy Rwanda it can take me to google.com[screenshot of expandable list view]
Here is my code;

List<String> afghanistan = new ArrayList<>();

    afghanistan.add("Hope Academy Rwanda(www.google.com)");
Royal
  • 51
  • 5

1 Answers1

0

For ListView you can set the item Clickable by as:

[yourlistview].setOnItemClickListener(new OnItemClickListener(){
   @Override
   @Override
    public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {

        // Here will be your Intent to open the link.

    }
});

And then under that you need set Intent to open a particular link:

String url = "http://www.example.com";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
Abhilash Maurya
  • 302
  • 3
  • 18