Change text of one specific context menu item - android

I've created a context menu for my recycler view items. In the menu I have Watch (like favourites), Share and Hide. Now what I want to do is get the specific position of the Recycler View and check if the Watch or Hide button has been pressed. How can I go about doing this? I've used a flag but that just checks the whole Recycler View so that doesn't work.
I can show source code on request too. I know it needs to go in my Adapter but can't figure out the position of it
Thanks in advance.

just add a boolean variable in your List to check whether to show Watch or Hide button.
use getAdapterPosition() method when user clicked the clicked on button and then use that position to update value in your model class.

Related

how to show and hide buttons in listView

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.

Android open ListView for multiple selection programmatically

I got a fragment with a ListView. The purpose of the list is simply checking items in that list, so I want to add something to the onCreateView method which will make the list enter its multiple selection mode automatically as the fragment shows, without the need for the user to long press an item. How can I do that?
to use longpress , you can do this way,
android:choiceMode="multipleChoiceModal"
or
setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL)
go through this for more information

Click on list view and and let it selected - android

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)

Custom Listener for a ListView item

I have a View with a ListView appended, which actually uses a custom view item done programatically. Inside each list item I have a button which I need to track, to update another item in the view. It is only invalidated when you click on the list item button, not anywhere else in the list item.
So I thought of creating a custom Listener. I trigger it when the button is clicked, but I have no way to access it from the ListView activity.
Is there a way to simulate those setOnItem...Listener's using a custom listener? Thanks in advance
Please see this link to help with how to set onClickListener from within custom ListAdapters.
You can use the myButton.getTag() and myButton.setTag() to put and get data to/from your View/Button.
See this link as well to help with custom ListAdapters.
Here is another good example I found of how to use a custom adapter.

Doubts in Using CustomListView

I just created a ListView, the itemclickevent works fine with it. But when i add a combox box to the list view, the focus goes within the selected object list in the object only, but cannot get the click event, but i can check or uncheck the checkBox.
Any Ideas how to use this? I want the click event for selected object as well as the check box.
I'm not sure I understand your question correctly. But if you want to get a itemClickedEvent for a listview Item at the moment the user checks a checkbox this is not easily possible.
The Checkbox will handle the press on it and because the event is handled the list won't get the information. You can try to set the clickable of the checkbox to false and check and uncheck the box yourself at the moment the user clicks the listitem.

Categories

Resources