Url as link in list in android

I am new to android and I am trying to contribute to an android project. There is a list of message views, and when the user clicks a button and a specific message, another view opens and shows the details as shown in the picture below (Android view).

android view

All this information is retrieved from the network and analyzed. and the link cannot be clicked on the webview as shown in the picture below (webview),

web view

It does not appear as a webview hyperlink. I think it is for this reason that it does not appear as a link in the android app.

Can anyone help me? The code associated with this can be found at: source  related files:

\scraper\MessagesScraper.java , 
\scraper\SingleMessageScraper.java , 
\ui\messages.java 
\ui\SingleMessage.java

      

Any help would be great. thanks in advance.

+3


source to share


3 answers


In your XMl, wherever you define that a certain TextView adds the following to that TextView

 android:linksClickable="true"

      

Also see How do I make links in a TextView clickable? if you want, for example, to hide the url and just show the text for the link.

Edit: from what I can tell ...



MessageScraper uses ThreeLineAdapter - https://github.com/pradeepb6/TuCanMobile/blob/master/src/com/dalthed/tucan/adapters/ThreeLinesAdapter.java Here you can see all text objects and then go to res folder and change accordingly them.

SingleMessageScraper seems to just use the standard ArrayAdapter and Androids Simple_list_Item_1 for layout. http://developer.android.com/reference/android/R.layout.html#simple_list_item_1 So if you need, you need to create your own list_item layout for this, if it makes no sense to use one that has already been created.

I don't think the UI classes need any changes.

Re: Comment - The only message (shown in the picture) is a list of TextViews. You can also have an idea of ​​custom views if you want to get more stuff in each cell, which is what the ThreeLineAdapter handles.

+1


source


If you are using TextView

ListView in your function getView

you can use Linkify to convert link to url



TextView textView = (TextView) findViewById(R.id.textView);
textView.setText("http://www.example.com");
Linkify.addLinks(textView, Linkify.WEB_URLS);

      

+1


source


WebView.getSettings () setJavaScriptEnabled (true) ;.

0


source







All Articles