Show the list as clickable - android

I have obtained a list of URL and subsequent title from a web service and I would like to show that the list is clickable.
I want to display the title to the users as
title 1 >
title 2 >
title 3 >
I believe the > signs denotes that these titles are clickable and would do something at launch
I have tried setting
android:clickable="true"
and also
android:clickable="true"
but one of these options show > in my list.
I have already implemented the setOnClickListener() and am able to launch URL with that however what I would like to do is display > next to the list to show they are clickable links.
Using the response given I have now managed to show the image.
However as the title is 3-4 lines long but I see the image only on the first line. Is there any android: (settings) which I can set which would allow the image to be aligned right and centre of the list row?

That's not in the default Android behavior.
You can find an image with the same shape, save it as something like link_arrow_right.png in your drawable folder, and use it on the TextViews that display clickable links.
This can be done in two ways:
1) In your layout xml, in your link text view item:
android:drawableRight="#drawable/link_arrow_right"
2) In your code, programatically:
yourTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.link_arrow_right, 0)

Related

AutoCompleteTextView - how to add an image and a text to auto completed text?

I have the following layout in my app -
What I want to achieve is the following -
1) The red line - I want to have above the suggestions a hard coded text saying "did you mean" and then the recommended. This text should be replaced when there are 0 characters in the AutoCompleteTextView and say "recent search". How can I do that?
2) The blue line - I want to have an image near each row item - how can I add them?
3) I would like to add a magnifying glass image before the searched text query starts to write. How can I add it?
As stated in the title, I am using AutoCompleteTextView.
You can create custom view for your autocomplete textview and set that view into adapter. custom view contain imageview and textview as you want in horizontal row.
still not getting idea check this Custom view for dropdown

Add views dynamically and get value from those views

I need help regarding adding new set of views and get value from those views.
In my example, I want to add 4 TextViews on Button click and open TimePicker from each view click and display new selected time on respective TextView.
Below is screenshot of view.
If these 4 views are fixed you could just create the xml and add them all to a single holder that you set invisible. If you mean by dynamic that it could be either 4 or 99 views, I'd recommend a RecyclerView. Plenty of examples on the internet. If you create a recyclerview with a custom adapter it is very easy to get the respective data per view.
For the future, please add more context to your question like what you've tried, what the result was and why this isn't your expected result. This is a very broad question.
Assuming that on clicking the clock button under the time section (on the right) you would want to set the selected time into the text field. You can simply call view.getParent() on click of the button and from the parent you can get the first child i.e child at 0 and set the text into the text field. This will work provided the button and textfield are within the same layout.

Customize dropdown (Picker) list in xamarin.forms

I am working on xamarin.forms. I am creating an app for android. In app I have a dropdown list. I am using Picker for it. I customized it to look like dropdown. Now I need to make the first Index item to nonselactable. Means user can not select the first item. If user click on it nothing should happen. But currently when user click on the first index dropdown gets collapsed.
One more thing that I have to add in dropdown is a Cross button at index 1. Means at index 1, on left side there will be Cross button and at center there will be text like Select item. And this whole row should not be selctable. If user click at cross button dropdown should collapsed.
Anyone have idea how I can do this?
You can use listview for dropdown and control its visibility as per need.I faced similar situation where I customized list view to enact dropdown.There is another thing I want to know about Picker.Does your picker accepts or adds string only or you could customize it to accept views or controls?

Android: Transparent Colored ListViews with Background

I have a doubt I have a listview and below it there is a background with a image. I would like to have the lists with a transparent color in order to see the image in the background with the ListViews color. I have tried using a selector but it just applies to the select item i the listview.
Maybe it is not very clear so for that purpose I attach the following picture where the listview and the background is shown:
As you can see the item background is with color but the image is still visible
Thank you very much
Add following property in ListView...
android:cacheColorHint="#00000000"
it is for transparent background of ListView.
More detail see Here.
You can also use an image editor to edit the opacity of the image/shape/gradient/whatever that you're using for the rows. I use Gimp because it's free. Here's what you need to do in Gimp: Go to the 'Layers - Brushes' window. Right-click the image layer and 'Add Alpha Channel'. Then just dial down the Opacity using the number picker (located above the layer) and File -> Export the image. Add this image to your project. Set it as the background for the List View rows. Then set the background for the List View itself to whatever you want to take up the entire background behind the List View.
I managed to achieve this with the RecyclerView by adding this line of code to the 'onBindViewHolder' method in the 'RecyclerView.Adapter' class:
((RelativeLayout) holder.itemView).getChildAt(0).setBackgroundColor(Color.parseColor("#00FFFFFF"));
Bear in mind that the view returned by the above cast expression is an 'android.support.v7.widget.CardView' that contains the list item layout

Selected item from list getting highlighted

In following list, when I click any item which has width equal to 2 lines (in below eg, CNX SMALLCAP), item gets highlighted appropriately.
Problem comes when I click any item which has width equal to 1 line (in below eg, ICICI BANK), then along with the clicked item half of the above and below item is also getting highlighted.
Highlighting is always using width=2 lines.
What can be done to remove this?
I tried using clearFocus() and clearAnimation() inside onListItemClick() , but no luck.
ANY HELP WILL BE LIFE-SAVER !!!
Since you have two lines, focusing both the lines when you have some content makes sense. Hence make the line which you are not using invisible or gone. You can also create separate custom adapter for your listview with single line.
I think you set the selected color on the ListView not into the ListView item i.e. TextView which you have display as item. You can either set selected color on TextView or just set the textview background color as #00000000
<TextView android:background="#00000000" />
using this you define the transparency of the textview color with this

Categories

Resources