13

Guys I am trying to add large text with a website link like (https://stackoverflow.com/questions/ask) in my textview Located in database I tried adding it directly like this image :

picture of my value in databse

picture of my value in databse

But it appeared in the application on the form Textview not clickable like this image :

output app

output app

protected void onPostExecute(String result) { // Parse les données JSON String id; String solution; try { JSONArray jArray = new JSONArray(result); for (int i = 0; i < jArray.length(); i++) { JSONObject json_data = jArray.getJSONObject(i); id= json_data.getString("alltext"); solution = json_data.getString("title"); prob.setText(solution); sol.setText(id); // Résultats de la requête } } catch (JSONException e) { Log.e("log_tag", "Error parsing data " + e.toString()); } } 
0

2 Answers 2

29

Set the AutoLink to web in TextView it will automatically detect the links

<TextView android:autoLink="web" android:text="This is Google http://www.google.com" android:layout_width="match_parent" android:layout_height="wrap_content" /> 

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much , please i have another question i want to make hyperlink like for example : (youtube.com) replace it by just Youtube
Use this code for hypelink text TextView textView =(TextView)findViewById(R.id.textView); textView.setClickable(true); textView.setMovementMethod(LinkMovementMethod.getInstance())‌​; String text = "<a href='http://www.google.com'> Google </a>"; textView.setText(Html.fromHtml(text));
12

First of All set the Text to TextView

lbl2.setText("hi http://google.com"); Linkify.addLinks(lbl2,Linkify.ALL); 

Linkify automatically the clickable the link and other text remain same.

3 Comments

thanks so much , for help me :)
my pleasure :) mark up if its really help you.
It's my pleasure @Divyaraj

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.