Custom AlertDialog with a List - android

I want to create this exactly AlertDialog, but I didn't know how to do it, How to change the typeface for the selected item and How to add this icon on the right for the selected item too

You can make dialog like this and set Id for it whenever you clicking any text that clickable text's Id is store in that Id's variable and do another thing set icon with boolean.
like,
if your position is matched with Id then icon will visible else it will invisible

Related

How to keep a listview item selected after clicking on it

I have an android app which uses a ListView. When I click on any item, there is a light gray color which appears and fades out. How can I make this gray color to remain on the selected item instead of disappearing? Please take a look at the gif which shows the scenario which I want to avoid.
Current Scenario
First of all you need to change background color on clicked.
take reference from here
And then add this line inside your listview's OnItemClickListener
listView.setSelection(int position);
You can set item Selected according to your need using this method
listView.setSelection(0);
listView.getSelectedView().setSelected(true);
OR
listView.setItemChecked(0, true)

Spinner dialog click outside text

I'm using a custom Spinner in a dialog mode. Each item element has one text. The text in each item line is very short, eg. "A", "AB", "BC", etc. In order to select a line I have to click exactly the text (the background is than changing into blue and the item is selected correctly). When I click outside this short text but in the item line it is not selected. Is it possible to force the selection when I click the item line not exactly the item text?
If you are using a custom spinner then you should be able to access the textview element in the xml for the class.
In this xml, the textview element try changing the property
Android:layout_width="match_parent"
You may also use the padding and margin to adjust the same.

Android Expanded ListView Selected Item icon change

Any one please suggest, How to change icon image of selected item icon in Expanded Listview? In my senario if once click selected item ,previous icon change to normal state and selected item icon change to selected state.
In ExpandableBaseAdapter's getGroupView, there will be argument called isSelected strong text
So by using that argument, change your view or background based on your need.
if(isSelected){
image.setBitmap(R.drawable.my_drawable_selected);
}else{
image.setBitmap(R.drawable.my_drawable_normal);
}

How to add a small icon to item listview when that item is on click?

I have a ListView and each item have a TextView.
I would like add a small icon when user click in that item. (when user click other, icon hide and show in the other)
any ideas, examples or tutorials?
thanks
You are going to need a custom ListViewAdapter. This website has a good tutorial:
http://www.ezzylearning.com/tutorial.aspx?tid=1763429
You could put an OnClickListener on each list item that associates the icon with that item and programmatically add the icon to its layout, while removing it from the previous' layout. So you'll want to have a variable that holds the current layout that is associated with the icon, and when a new item is clicked you remove the icon from that layout, then set the variable to this new item's layout.

android change view of selected item in adapterview

I have a listview with a textview as each item. I want to change the textcolor of the selected item. For this use the onItemSelected method to make the changes. Say first I select the 1st row, the first row's textcolor changes. Now when I select the 2nd row, its text color also changes, but I want the 1st row's color to change back to its default color. How do I do that, since in the onItemSelected I only get the refernce of the currently selected item and not the last selected. Is there any way other than holding a reference to the last selected view.
When first item is selected store its position in instance variable of your activity, lets name it currentlySelected. Then combine with this Android: Access child views from a ListView
in order to get the view at position currentlySelected and change it's textcolor.
Instead of doing it in Java, you can let android handles it in the xml file. See Color State List Resource.

Categories

Resources