Click on list view and and let it selected - android - 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)

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.

Change text of one specific context menu item

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.

How to set the list view position first when the button clicks?

I want to do when the button clicks, the list listed from the top if click again it shows the last item
How to do this
sorry for my poor english
To reposition your list view use setSelection, something like:
position = data.lenght() - 1;
listView.setSelection(position);

How to set selector true on back to grid view

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.

Clicking List-view row and child Button as well

My ListView's row has one Button. Now i want to set click event to both row and button. But as i know ListView loose its onItemClick property if we set it's child click event. So please guide me a way to doing both at once
If you are using Buttons inside each list item, then set the click listener for the buttons on not on the list item.
Button.setOnClickListener(View.OnClickListener)
The list item clicks should go ignored and the buttons click listeners should do what you want.
You have to use ListView.setOnItemClickListener(OnItemClickListener). See the tutorial.
In OnItemClickListener.onItemClick() you're provided with the position of the item.
I don't understand why you don't want to use ListView.setOnItemClickListener(OnItemClickListener) ?
Because it react instantly to a touch event. Isn't what you want?

Categories

Resources