How to cancel recyclerView scroll? [duplicate] - java

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

Related

How to put gif in Button's background? Android [duplicate]

This question already has answers here:
Set Animated .GIF As Background Android
(3 answers)
Closed 4 years ago.
I would like to know how to put a gif in a Button's background on Android.
I already found out how to put a gif in an image view but I can't find any answer for my problem.
Buttons do not support gifs as a background resource.
Why does it has to be a button?
Just use an Image-View and react to an onClick event.

Change functionality of back button [duplicate]

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

Both click and longclick respond in listview [duplicate]

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. :)

How to use a method to swipe between activities? [duplicate]

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

How to style view to look like a ListView [duplicate]

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));

Categories

Resources