I need to make a spinner like on picture below. My question is - how to add arrow(dropdown hint) to right part for first element in spinner. Better if it(I mean arrow but not "Select test") will disappear after user press it
Add in spinner arraylist zero position as "Select Type" and you want to add arrow So,you need to take image view in right side of your spinner,and when you get spinner item selected position is 0 at that time you need to visible imageview and other position hide imagview.
I hope this can help you!
Thank You.
Related
I have an android application with a drop down list which have left and right icon, I try to use spinner with left and right drawable, but does not work, what I need is look like below where user can only enter (select) from the list, which mean autocomplete text is not useful, also dropped list does not contain image, How can I achieve that?
So after better understanding your idea, this is the steps you need.
create a custom adapter (this should take the list of string you want to display and the list of icons )
list item is one edit text like
<EditText
...
android:drawableLeft="#drawable/my_icon" />
create your spinner and set the adapter
Spinner sp = findViewById(R.id.spinner);
sp.setAdapter(your custom adapter)
add the item selected listener and you are done.
More info on adapters
You need to use a custom spinner With Image And Text and a card view back ground for spinner. check this link how to add drop-down menu spinner. https://stackoverflow.com/a/24422359/2546742
As shown in the image when I click on an item in the list view. Buttons show up.
I want to hide buttons when I click on different items and show on current clicked item.
How can I make it work?
Need to preserve view into a variable like prevView. and then click on another item.
Check whether prevView is null or not. If not null. then get button id .
e.g. prevView.findViewById();
and Make their visibility.GONE. and also null prevView.
I hope this will help you.
You can achieve this by making a model class.
take variable for particular buttons in Model. after clicking on a different item set true/false tag in the model and show/hide view according to that tag.
You should be using an expandable ListView so that you can get the buttons shown when you tap on the list item and it get closed when you tap on the other item in the list.
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)
i want to show a image and text on spinner & dont want to see the dropdown, look at the image shown below, like this need to have text and image. i.e image at left side and text at right end. Also we require selection happening on the spinner.
Eg: If i click on setDate the calender should come and chosen date should sit on spinner.
just add following line for disabling spinner:
spinner.setClickable(false);
and for selecting your row you can use following code:
spinner.setSelection(spinnerPosition);
that spinnerPosition is that position that you want.
Hello I have a listview set up with an icon to the left of each row using a row.xml. When the activity is started i would like to have one icon but when a the menu is opened and an item there is selected i want to change the icon in just one position. For example
I Cat
I Dog
I Mouse
I Food
Where I is my icon and the rest then the rest is my list i would like to change just the I in the second position so that the list would look like this
I Cat
D Dog
I Mouse
I Food
So some how get all the positions and then do like
for (position 1){
change the imageview
}
But i still want the first listview to be the default how can i change the icon of just one row? Thank you for any help
What's your underlying data structure that you're binding to? If it's a Cursor you could call notifyChange on a Content resolver to let the adapter know the data has been updated.
Ended up doing this
ImageView imageView = (ImageView) lView.getChildAt(position).findViewById(R.id.checkbox);
imageView.setImageResource(R.drawable.checkbox);