android-recyclerview

RecyclerView first and last item are changed, when clicking only one

走远了吗. 提交于 2021-02-04 19:16:47
问题 I'm using a recyclerview to display a list of interests one could choose from. Clicking the very first item makes the very last item also selected Selecting first item: Last item is also selected: The selection is done with this code: @Override public InterestViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { TextView v = (TextView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.interests_textview, parent, false); v.setOnClickListener(new View.OnClickListener() {

ViewHolder views must not be attached when created

江枫思渺然 提交于 2021-02-04 14:28:29
问题 I'm trying to create a simple RV that will show a TextView. This is my adapter: public class MyRvAdapter extends RecyclerView.Adapter<MyRvAdapter.ViewHolder> { private String[] mDataset; public static class ViewHolder extends RecyclerView.ViewHolder { // each data item is just a string in this case public TextView mTextView; public ViewHolder(TextView v) { super(v); mTextView = v; } } public MyRvAdapter(String[] myDataset) { mDataset = myDataset; } @NonNull @Override public MyRvAdapter

how to remove divider between items of Recyclerview in android

风格不统一 提交于 2021-02-04 13:07:38
问题 i want to remove divider (space) between items of RecyclerView So try to set background of item view and RecyclerView to White ,but it doesn't works how to fix it ? Item View XML : <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:background="@android:color/white" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="match_parent"> <LinearLayout android:background="@android:color/white" android

how to remove divider between items of Recyclerview in android

馋奶兔 提交于 2021-02-04 13:04:17
问题 i want to remove divider (space) between items of RecyclerView So try to set background of item view and RecyclerView to White ,but it doesn't works how to fix it ? Item View XML : <android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" android:background="@android:color/white" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="match_parent"> <LinearLayout android:background="@android:color/white" android

Pass data from adapter to activity using interface callback method with Kotlin

折月煮酒 提交于 2021-01-29 21:49:31
问题 I have read through this Kotiln: pass data from adapter to activity and am attempting option 1 from the answer given. I have a game with various levels. I send all levels to a recycler view using the the below itemview in gridlayout <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout

How to prepare setSpanSizeLookup in GridLayoutManager

心已入冬 提交于 2021-01-29 19:01:01
问题 i need every 18,36,54,...18*Nth... grid with layout with width:match parent and height:60dp in grid layout manager for pagination loadingbar purpose. Here is my code, GridLayoutManager mng_layout = new GridLayoutManager(this, 4);//WHAT IS 4 ?// mng_layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() { @Override public int getSpanSize(int position) { int mod = position % 6; //WHAT IS 6 ?// if (position == 0 || position == 1) return 2; //WHAT IS 2 ?// else if (position < 6) return 1

How to show progress dialog until the data loads in FirestoreRecyclerAdapter

一笑奈何 提交于 2021-01-29 17:10:50
问题 I am using FirestoreRecyclerAdapter to load the data from Firestore into RecyclerView . I would like to show progress dialog until the data loads completely. How do I do that? Thanks in advance. Here is my code so far. void loadPosts() { FirestoreRecyclerOptions<Post> options = new FirestoreRecyclerOptions.Builder<Post>() .setQuery(query, Post.class) .build(); adapter = new FirestoreRecyclerAdapter<Post, DataViewHolder>(options) { @Override protected void onBindViewHolder(@NonNull

How To add swipe Left to Right in recyclerview

我的梦境 提交于 2021-01-29 14:25:15
问题 I am trying to add swipe function for my recyclerview. I am following this link for adding swipe. https://github.com/nikhilpanju/RecyclerViewEnhanced/blob/master/recyclerviewenhanced/src/main/java/com/nikhilpanju/recyclerviewenhanced/RecyclerTouchListener.java In this link I can do only Right to left swipe. I want add Left to Right swipe. I tried to add functionality in onInterceptTouchEvent . But I can not do the Left to Right Swipe. Can any one help me to add Left to Right swipe? 来源: https:

Items not displaying in RecyclerView

北城以北 提交于 2021-01-29 12:30:48
问题 That's a weird problem I'm facing right now. From my app, I'm fetch data from JSON file from a link then parse it with Volley. Now I want to display the data on a RecyclerView which doesn't seem to work, I'm pretty dure that my code is good but something doesn't seem to work and I can't find it. activity_home.xml This seems to render as I tested wiht background color: <?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas

Get parent key value on click of child in recyclerview from firebase database

老子叫甜甜 提交于 2021-01-29 12:08:47
问题 I am creating a recycler view in which, I am getting Survey Name which is child of survey reference number in firebase database. What I want is when user click on survey name in recyclerview list it gets the parent KeyValue (which is survey reference number). I have attached the image of the database. On click survey name encircled which blue line, I want the parent key shaded with yellow line I have used an Interface in adapter class where I am getting position and modelResponse public