Linkify TextView - android

i have listview and i call intent from the listview onitem selected method
but when i get linkfy textview in my listrow than i am not able to call intent from the onItem selected method.
Any suggestion would be helpful to me.

I'm a little short on detail here, but it sounds like you want your text to look like a link while still using the list view's onListItemSelected method to handle clicking on the link.
I haven't used 'linkify' in a textview before but I suspect it might be overriding the click/touch event that the list would otherwise be using (to act as a link instead).
If you still want it to look like a link while using the onListItemSelected method, you could easily modify the textview's text color to blue instead, though underlining the text might be a bit more difficult to achieve.

Related

ListView clicklisteners

I have a list view which has a couple of views within it, I have a textView and an ImageView.
What I need to do is, I want a person to be able to click just on the imageView without causing the onItemClicked function to be invoked, If the person clicks the ImageView, it should do something else, but if the person clicks away(apart from the imageview) from the imageView, then the onItemClicked is fired.
How do I do this?
It is kinda like, the listView on the android phone callLogs whereby, the green phone icon is somehow separated from the list but when clicked, it should know which listItem was selected and act accordingly.
I will appreciate the help. Thanks.
Here are some links for you are looking for. Advanced but if you stick with it and dont give up on this, you will learn a ton!!! Take a look:
Android: ListView elements with multiple clickable buttons
Android custom list item with nested widgets
use holder.imageView.setOnClickListener() in getView() method of adapter class.

Different OnClick actions for subviews in ListView item and fancy context menu bubble

I'm writing an app and I have a ListView, which items are ImageView and TextView.
I'd like to determine whether user have clicked the icon or the text to handle diferrent actions for each case. I want to achieve similar effect like in stock contacts app.
First question: How to achieve the effect wich I've mentioned above?
Second question: In the stock contacts app when we click on a photo, a fancy bubble with some actions inside appears. How is it called? Where to get it from?
Thanks.
(edit)
ok, i've found something according to my second question:
How to make a fancy transparent menu like the "share menu" in Android gallery?
The answer on your first question: you should attach onClickListeners to each of your row's views in your Adapter's getView() method. This should do it.

Clickable item with clickable urls in ListView

I have custom ListView item with ImageView and TextView. TextView contains HTML string with urls and some regular text. Im my adapter I have code similar to
tv.setText(Html.fromHtml("<a href='http://google.com'>google</a>"));
tv.setMovementMethod(LinkMovementMethod.getInstance());
and this works great but onListItemClick isn't executed when I click on item outside url, whole item looks like inactive.
When I click on url I want to fire default action form urls and when I click on regular text or on ImageView I want to execute onListItemClick is it possible?
Second question, is it possible to start activity using start some activity?
You can't make an intent form an anchor.
It's ok and recommended that you use onListItemClick (it saves you a lot of work), and if you want to open the link in the browser (without using a webview) you can use this an intent, this is an example:
Intent myIntent = new Intent(Intent.ACTION_VIEW,ContentURI.create("http://www.google.com"));
startActivity(myIntent);
Hope this helps.
You need to specify a callback for each of the views that you wish to select. I believe you have three different items: The Listview object, which contains a TextView and an ImageView.
If you would like to have different behavior for each different piece, you need to create a callback for each different piece. You can set a callback in the XML declaration of the view by setting
android:onClick="myCallback"
http://developer.android.com/reference/android/view/View.html#attr_android:onClick

get a small list when clicked on a button

i have a image view and on top of it i have a button. now what i want is when i click on the button i should get a list of images on same Activity.actually i am trying to make a list in button,s onClick event. event gets fired but it does not show the list. anybody can have any idea how shall i achieve this i am also making my layout programmatically.
thanks alot
Without seeing some code it's hard to give a definite answer, but these are a few possibilities.
Create the listview together with the button, but set it's visibility to View.GONE or View.INVISIBLE. In the button's onClick method, set it to View.VISIBLE.
Alternatively, do the listview creation in the button's onClick (which I gather is what you're doing?), making sure you don't forget to add it to your layout. I have no idea why this does not work for you. Show some code or use the debugger to step through it and find out where it goes wrong.

EditText.setMovementMethod with LinkMovement Method in ListView - loses ability to "Click" on rows in the list

So, basically I have a custom View that contains a ListView with a custom Adapter that has the ability to read in information from the network (dumbed down HTML) and display it on a row by row basis.
All of this works, but I need the text that is read in to be parsed as HTML which contains links that can be tapped on and launched in browser.
I managed to do this by:
text.setText(Html.fromHtml(textBuffer), TextView.BufferType.SPANNABLE);
text.setMovementMethod(LinkMovementMethod.getInstance());
Works great, any links in the text are displayed as links and can be tapped.
This is a side effect of now making it so the rest of the rows in the ListView cannot be tapped (or tapped and held). Basically, all the rows are non-selectable now.
Is there any way to achieve both of what I need?
thanks!
Try setting text.setFocusable(false). By removing focus from the EditText, events will be passed onto the ListView or other items.
When you put an item that is focusable inside a ListView, it automatically makes the ListView not focusable. This is the behavior you are seeing.
To make them both focusable, I believe you can adjust the descendantFocusability property of the ListView.
See this question for a similar problem.

Categories

Resources