This question already has an answer here:
ListView Click and LongClick
(1 answer)
Closed 5 years ago.
I have implemented both onItemClickListener and onItemLongClickListener in my ListView.
- itemClick to start a new activity;
- itemLongClick to open a popup.
But when I longpress an item both listeners react.
How do I set OnClick not to respond when I longpress?
You need to return true in LongClick then onClick will not be called. Look at this: how to implement onItemLongClickListener and onItemClickListener event on listview row in android?
This question has been answered previously on this forum. :)
Related
This question already has answers here:
Android - How To Override the "Back" button so it doesn't Finish() my Activity?
(10 answers)
Closed 5 years ago.
I have a recyclerView in a fragment which I use it to show some items. When selecting these items I change my toolbar title to number of selected items and also I change menu options. how can I make pressing back button cancel the selection operation?
You override the
onBackPressed()
Method and do what you want there. Any back key press will trigger this function and you'll be able to use your logic
This question already has an answer here:
Stop user scroll to set position on RecyclerView
(1 answer)
Closed 7 years ago.
How to cancel recyclerView scroll? I don't need let recyclerView to scroll!
I try to do recyclerView.setFocusable(false), but it doesn't work!
RecyclerView has a stopScroll() method to stop a scroll in progress
This question already has answers here:
Android: How to enable/disable option menu item on button click?
(12 answers)
Closed 7 years ago.
I want the options menu with icons from the api level 11 when the menu button is clicked.If it is not possible after api level 10 then please suggest me how can I do this.
Thanks in advance.
The options menu is deprecated as of API 11; use the action bar or a navigation drawer instead. See: http://android-developers.blogspot.com/2012/01/say-goodbye-to-menu-button.html
This question already has answers here:
Swipe between activities
(2 answers)
Closed 9 years ago.
I have two activities with two different layouts.Right now i have to click a button to change to the other layout, but i wanna to swipe on the screen, is that possible?
If you make your two layouts as Fragments, then you can use the ViewPager to swipe between the fragments in the same activity.
http://developer.android.com/training/animation/screen-slide.html
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Getting the Listview default clicked color, depending on the Device
I would like to style a View to behave like a ListView. It means that when I click on it, the background color changes. I can't do this by setting a custom color because each device has a different style for this component.
Any ideas how can I do it? Is there any system style I can apply on it?
setBackground(res.getDrawable(android.R.drawable.list_selector_background));