android-recyclerview

Focusing on a recyclerview item

拜拜、爱过 提交于 2020-01-04 09:25:42
问题 I am trying to focus on a particular item of a recyclerview. What is the equivalent of the listview.setSelection(position) when using a recyclerview. 回答1: You call RecyclerView.scrollToPosition(position) to request the RecyclerView's LayoutManager to scroll to the given position during the next layout pass (it's asynchronous). To request focusing an item view, the view must be focusable and you call View.requestFocus() . If the view is not yet laid out at the time you want to focus it, you

How do i store the json response from my server to an arraylist and pass to next activity?

◇◆丶佛笑我妖孽 提交于 2020-01-04 07:51:23
问题 I am using Retrofit and the server returns JSON object as response. I want to store it in an ArrayList and pass it to the next activity where it can be displayed in RecyclerView . I am not getting any error but there is no output on the Display activity. What could be the problem? Here is my main activity. public class MainActivity extends AppCompatActivity { public static final String ROOT_URL = "http://walletuncle.com/"; String username; String password; private Button makerequest; private

Android: RecyclerView: No adapter attached; skipping layout

扶醉桌前 提交于 2020-01-04 06:26:07
问题 I keep getting the error "RecyclerView: No adapter attached; skipping layout" when the RecyclerView list is shown. I have 3 tabs and one tab has a RecyclerView list that is populated from SQLite database. I don't get any crashes and the data is shown correctly in the view but I still get this error. I thought it was just a warning because the data is in place correctly but when I tried onClick it doesn't work and I'm sure it has something to do with this error. I know this question has been

Filling an adapter from different LiveData sources

断了今生、忘了曾经 提交于 2020-01-04 06:25:30
问题 I'm playing with LiveData and want to understand what it can do. I want to fill my RecyclerView with data from different sources by switch(using filters if you like). Filtering values inside an adapter is not an option. So, I decided to use MediatorLiveData inside my view model. Dao: @Query("SELECT * FROM tasks WHERE completed = 0") LiveData<List<Task>> getActiveTasksLiveData(); @Query("SELECT * FROM tasks") LiveData<List<Task>> getAllTasksLiveData(); @Query("SELECT * FROM tasks WHERE

RecyclerView on Click Listener Not working

狂风中的少年 提交于 2020-01-04 06:06:11
问题 When i want to click recycler view then it should open another Activity Data is fetching but the problem is when i click on recycleview it displays nothing. I tried RecyclerView.OnItemTouchListener. but no Success yet. Can You please figure it out whats the issue,where i am going wrong public class RestaurantAdapter extends RecyclerView.Adapter<RestaurantAdapter.MyViewHolder> { List<AllRestaurant> restaurantList; @Override public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType)

How to Exclude item from FirebaseRecyclerAdapter or Firebase Reference Android

谁说胖子不能爱 提交于 2020-01-04 05:47:06
问题 I'm working on Activity to show all the others app users except my user and i'm using Java android with Firebase . But i cant find anyway to exclude item from DatabaseReference or from FirebaseRecyclerAdapter . My Activity look like this My Database look like this : My code inside this Activity looks like below : @Override public void onStart() { super.onStart(); database = FirebaseDatabase.getInstance(); myRef = database.getReference().child("users"); FirebaseRecyclerAdapter<Users

How to have swipe to delete and swipe to archive in two colours in Recyclerview Android

天大地大妈咪最大 提交于 2020-01-04 05:12:22
问题 Right now I have a funtional swipe left to delete in recyclerview with two layouts(foreground and background). I use itemtouchhelper in the code. However, I would like to have BOTH swipe left and swipe right showing different colors and icons, like in Google Inbox. How can I implement that? What I want is: swipe rightswipe left what I have is: only swipe right the code is just the standard itemtouchhelper.simplecallback with 2 layouts in the xml. And I googled everywhere and only found single

Implementing RecyclerView with collapsing toolbar layout

时光毁灭记忆、已成空白 提交于 2020-01-04 03:55:07
问题 I'm trying to implement RecyclerView with collapsing toolbar,but i'm facing the problem as RecyclerView comes upward on collapsing toolbar.What i want to acheive that it should be down and comes up with collapsing toolbar. please help? Below is the image what i'm currently getting the result. here my code <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas

RecyclerView scroll to top with AsyncListDiffer not working

a 夏天 提交于 2020-01-04 01:53:04
问题 I am using RecyclerView with AsyncListDiffer (calculates and animates differences between old and new items, all on background thread). I have a button to sort the list. After I sort it and re-set it to RecyclerView using mDiffer.submitList(items); I also call recyclerView.scrollToPosition(0) or ( smoothScrollToPosition(0) ), but it has no effect. I think this behaviour is expected, as AsyncListDiffer is probably still calculating differences at the time that scrollToPosition(0) is called, so

RecyclerView scrolls to top position when change the adapter data

江枫思渺然 提交于 2020-01-04 01:24:41
问题 I am doing the like and dislike for a post in a RecyclerView , I call the api after changing the view but the problem is that the RecyclerView always scrolls to the top when I notify it with the updates. this is my adapter code : likeAnim.setOnLikeListener(object : OnLikeListener { override fun liked(p0: LikeButton?) { if (commentList[position]!!.liked) { // likeButton.setBackgroundResource(R.drawable.heart_ico) isLiked = false callback(commentList[position], 2, layoutPosition) } else { //