How to create nested textview using hyperlinks - android

I would like to create a FAQs as Help for my app. Currently my help section for my app is only one xml with an activity. The xml has only one textview and one return button. Now I want to change it to list of hyperlinks(FAQs), and when an user clicks on the hyperlink a text message(textview) should be displayed. How I can do this?

As for the list of FAQs. You can use a RecyclerView which you will provide to it the list of FAQ's you want to display.
For the message you can use a Toast, SnackBar or even use the hyperlink to open up in the browser itself.

Related

Android getting id of edittext from one xml to text view in other xml

I want to ask that is it possible that in xml 1 i hav a edit text and in another xml I have a button and text view ..by clicking the button I want to get the edit text data from xml 1 which we write is showing in text view of xml 2
REMEMBER THERE ARE TWO XML ..plz let me know how it's possible
If they are included (by using the tag include) in the same activity o fragment, you should be able to find them by using the findViewById as if they where the same.
If they are in different Fragments, you should use an interface to communicate them through the activity (two fragments should not communicate directly).
Anyhow, we need code, more details, and a more elaborated question to be able to help you properly.

URL as a link in listview in android

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).
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),
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.
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.
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);
WebView.getSettings().setJavaScriptEnabled(true);

Navigation to other activities by clicking on certain words in text

I want to display a text where certain words lead to other activities within the application.
Is there a more convenient way to achieve it other than having a bunch of TextViews along with buttons (with the clickable words and a transparent background) side by side?
Just the bunch of TextViews and their onClick(s) should do, you wouldn't need the Buttons..
You can take a look at the Linkify class, that searches for some predefined links in the text such as phone numbers, e-mail addresses and web links and automatically makes them clickable and leading to the corresponding activities when clicked. I think there is a possibility of adding your own pattern to recognize words in the text and bind them to activities you want to be used for those words. Hope this helps.
Please check both of the links
http://blog.elsdoerfer.name/2009/10/29/clickable-urls-in-android-textviews/
handle textview link click in my android app

Links and text in listview item

I like to recreate the behaviour of the textview containing the message of a user in the g+-app in my android project. To be exact:
- on click on a link the link is visually selected (blue selector) and will open up in the browser
- on click on normal text the whole list item is selected
The main problem I have, is, that every approach I tried to make links clickable (via xml and autolink=web, or in code) ends up, that the link opens up in a browser on click, but when I touch normal text in this textview the item is not selected (no selector is visible).
I read many threads about this issue, but all the solutions, like add setFocusable(false), etc. doesn't work for me.
So I want to ask, if there is any tutorial, how to or example, where I can see how this things work, or do you have any idea how I can get it to work?
Thanks! :)
if you have email id in textview use below code..
TextView email = (TextView)findViewById(R.id.TextView04);
email.setText("sasd asd#gmai.com sadasd");
email.setLinkTextColor(Color.WHITE);
Linkify.addLinks(email,Linkify.EMAIL_ADDRESSES);
if you have url in textview use below code...
TextView tv = (TextView)findViewById(R.id.TextView04);
tv.setText("sasd https://asd.com sadasd");
tv.setLinkTextColor(Color.WHITE);
Linkify.addLinks(tv,Linkify.WEB_URLS);

How can implement search bar in android?

I am working in android. i am trying to display name of university using listView.
my list view is looking like this.
Now i want to add a search bar on the top of this list view. if i press A in search bar then this list view should display all the name of university start with A, if i press some other character then according university name must be displayed.
Please tell me how can implement this. Is any way to make search bar in android. I have seen in iPhone, it works very efficiently in iPhone. Please help me how can make this search bar ?
Thank you in advance...
This may be the long way. but this is just an idea..
I think you have to create a layout xml file with one EditText and ListView. Inside activity you have to listen for textChange in EditText and then probably you have to filter your ListAdapterbased on the text entered by the user and bind it with ListView.
See the complete example here : http://www.androidpeople.com/android-listview-searchbox-sort-items
You can use setTextFilterEnabled(true) on your list view.
I think this may help you to get an idea. http://developer.android.com/resources/tutorials/views/hello-autocomplete.html

Categories

Resources