1

I have the following code:

try {
            jArray = new JSONArray(result);
            JSONObject json_data = null;
            String myString = null;
            for (int i = 0; i < jArray.length(); i++) {
                HashMap<String, String> map = new HashMap<String, String>();
                json_data = jArray.getJSONObject(i);
                map.put("id", String.valueOf(json_data.getString("news_id")));
                map.put("title", json_data.getString("news_title"));
                myString = myString + "| "
                        + json_data.getString("news_title").toString();
            }
            String myString1 = myString.replace("null", "");
            txt1 = (TextView) findViewById(R.id.twxmorq);
            txt1.setSelected(true); 
            txt1.setText(myString1);

I am printing whole title in text view with marquee style in single line with ' ! ' partition. Now I want to apply onclick on each title and open it in new activity with detail news in web view.

Detail news will load with this data:

"http://www.taxmann.com/TaxmannWhatsnewService/Services.aspx?service=getnewsdetails&newsid=" + id  

Where id will differ for different title. Can you please tell me the logic or post some code for Implementation? I'm not able to do this.

Hesham Saeed
  • 5,358
  • 7
  • 37
  • 57
Anil
  • 83
  • 3
  • 8

1 Answers1

2

Either in layout xml file, for TextView attribute add,

android:autoLink="web"

Or,

txt1.setMovementMethod(LinkMovementMethod.getInstance());
user370305
  • 108,599
  • 23
  • 164
  • 151
  • but how particular title id will recognize its own id? – Anil Aug 21 '12 at 09:08
  • For this you have to make a URL for every Title with specified Id of that news. Look at http://stackoverflow.com/questions/2734270/how-do-i-make-links-in-a-textview-clickable – user370305 Aug 21 '12 at 09:10