I use grid view here, and i do open an full image on click of grid view item
When i do back press to my Grid view i want my last selector position true.
please help me to find out this
Thanks in advance
An easy way is to save the gridview position of the clicked element when clicked. Use SharedPreferences. You can load the status in the onResume() function.
Related
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.
In my layout I have a button and a listview. How can I change the imageview of item I selected when the button is clicked. So lets say, I select 5 items, and after I click the button, images for those 5 items will be changed.
So I am confused what function I should use. Right now i used button.setOnClickListener but it seems wrong because only the very first item's imageview will be changed when button clicked. Should I use listview.setItemOnClickListener? Or is there any other way I can do this?
Thanks a lot!
Add a boolean to the data object in your adapter. Say you've got ArrayAdapter<MyDataObject>. Add some kind of "selected" field in the MyDataObject, and toggle it when you "select" the row.
Override getView in the adapter (you'll need a custom Adapter, btw. I'd just extend ArrayAdapter). When you render the row, if the "selected" field is true, show the "other" image.
When you click the button, call 'notifyDataSetChanged' on the adapter. The will cause the visible rows to refresh themselves (and call getView for each).
I think that'll work.
Since you only want images to change when you click the button, you'll need to have some kind of global boolean, so the getView won't show the image until the button has been clicked.
The complication here is, you have to deal with rows that may have been scrolled out of view, which don't have active views, but logically exist. It would be really hard to explain the concept here. I'd suggest some tutorials on ListView if you're not familiar with the recycling of row views.
You can used custom baseadapter for listview and setonclicklistener in the getView() method.... see tutorial here this is hope for help
You can use button click listener as well as on itemClickListener too but to make a image view in selected state in a list, you have to call setSelected method of imageview parent layout.
Please put a comment if you don't get me.
Thanks
I have a list view with custom adapter. I'm trying to implement following
when a item in the list is clicked, only that item is expanded and show some info.
when it is clicked again, it goes back to the first state. can any one suggest a
way to achieve this.
thanks in advance
Use ExpandableListView.
It can help you.
ExpandableListView can expanded and back to the first state.
Also, you can custom inner layout.(some info)
please use it.
I have listview with image and text. Image and text are coming from sqlite. I got the selected item text. But till now i cannot get the selected image. how can i get the selected image and how to pass that image to next activity? can anyone help me...
Thanks in advance
use AdapterView.OnItemClickListerner, you will be notified when the list item is clicked. In the callback method, you will be provided some parameter which can help you determine the data of selected item.
In some case, If you want to handle the click event by your self with OnClickListener, you have to enable focus-able and clickable abilities of list-item inside the Adapter#getView() method. Then, you just anchor the bitmap to list-item by call View#setTag().
Hope this helps.
I am looking for something in which
For eg. if i click on the list item... the view stay selected. is that possible?
I want this because... the content of the view is large so i have set marquee property to the textview, and that will only work if I list view is selected. so I want something...
If user click on view it stays selected
Thank you.
Yes it is possible. On the callback fired when you press on a item you can invoke:
View.setSelected(boolean)