3

I am new to android and I am trying to contribute for an android project. There is listview of messages and when a user clicks and a specific message, another view opens and shows the details as shown in below image(android view).

android view

All these information is being fetched from web and parsed. and link is not clickable on web view also as shown in below figure (webview),

web view

It is not shown as hyperlink on webview. I think that is the reason its not showing as a link in android app too.

Can anybody help me with this? The code related to this can be found at : source related files are:

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

Any help would be great. thanks in advance.

Christian Abella
  • 5,747
  • 2
  • 30
  • 42
Pradeepb
  • 2,564
  • 3
  • 25
  • 46

3 Answers3

1

In your XMl wherever you define that particular TextView add the following to that TextView

 android:linksClickable="true"

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

Edit: From what I can tell...

MessageScraper is using ThreeLineAdapter - https://github.com/pradeepb6/TuCanMobile/blob/master/src/com/dalthed/tucan/adapters/ThreeLinesAdapter.java You can see all the TextViews here and then go to the res folder and change them accordingly.

SingleMessageScraper seems to be just using standard ArrayAdapter and Androids Simple_list_Item_1 for the layout. http://developer.android.com/reference/android/R.layout.html#simple_list_item_1 So if you need to you'll need to make your own list_item layout for this if it doesn't make sense to use one that was already created.

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

Re: Comment - A single message (shown in your picture) is a listview of TextViews. You could also have a listview of custom views if you want more things in each cell, which is what the ThreeLineAdapter is handling.

Community
  • 1
  • 1
thurst0n
  • 155
  • 1
  • 1
  • 12
  • It's not a text view. It's a listview(singlemessage.XML). . I tried to change it to textview and run the application but I got a fc. – Pradeepb Apr 27 '15 at 23:47
  • Sorry for the confusion. So you should have an XML that defines the listview. But typically you'll have another xml that defines each item within that listview, so if you have a list of TextViews then that TextView should be defined somewhere and that's where you'll want to add that. It *looks* like it's just TextViews but is each cell actually a custom layout of it's own? Are you using a custom data adapter or just a ArrayAdapter? – thurst0n Apr 28 '15 at 00:05
  • Thanks a ton mate. I created custom (customlistview.xml) view like you suggested and added autoLink=web and it works. :) – Pradeepb Apr 28 '15 at 00:51
  • Awesome man I'm glad to hear that. Yea, if you want to do anything besides the most basic list items then you have to implement a couple xmls and the custom adapter with getView(). Take it easy! – thurst0n Apr 28 '15 at 01:21
1

If you are using TextView in your ListView's getView function, you can use Linkify to convert the link to URL

TextView textView = (TextView) findViewById(R.id.textView);
textView.setText("http://www.example.com");
Linkify.addLinks(textView, Linkify.WEB_URLS);
Christian Abella
  • 5,747
  • 2
  • 30
  • 42
0

WebView.getSettings().setJavaScriptEnabled(true);

Thinsky
  • 4,226
  • 3
  • 13
  • 22