android-recyclerview

Facing issue in Position value during Drag and drop in RecyclerView android

别等时光非礼了梦想. 提交于 2019-12-06 10:03:25
问题 How do i get new position value during drag and drop in RecyclerView adapter? Drag and Drop is working perfect but when i set setOnClickListener to open my detail activity. it gives me the old position value. For example : If i drag 2nd item (INDEX 1) and drop at 1st item's position (INDEX 0). On debuging inside setOnClickListener when i am calling Intent. Position value is 1 (INDEX 1) but what i need is value 0 (INDEX 0). @Override public void onBindViewHolder(final ItemViewHolder holder,

FirebaseIndexRecyclerAdapter onDataChanged is called but getItemCount() always return 0

梦想与她 提交于 2019-12-06 09:43:45
I'm using FirebaseIndexRecyclerAdapter which gets a keyRef and dataRef and is very helpful with getting all dataRef's children which their keys exists as children in keyRef. The data is being displayed correctly but if i'm overriding onDataChanged for hiding a progress bar and/or displaying an empty state depends on the itemsCount (Something which i've already done with FirebaseRecyclerAdapter and works as expected) but getItemCount always return 0(!) private class MYAdapter extends FirebaseIndexRecyclerAdapter<Item, ItemHolder> { . . @Override protected void onDataChanged() { super

Getting recyclerview position and passing object on click

笑着哭i 提交于 2019-12-06 09:32:10
问题 I really need your help here guys, i'm stuck. In short i have made recyclerview to show my parsed json data. What i'm stuck at is on how to get recyclerview position and pass json object to new activity trough intent. Here is my code so you can see whats going on. MainActivity: public class MainActivity extends AppCompatActivity implements SearchView.OnQueryTextListener { ArrayList<Item> end = new ArrayList<Item>(); RecyclerView recyclerView; Adapter adapter; List<Item> mModels; Context

Unable to add custom font in RecyclerView.ViewHolder

浪尽此生 提交于 2019-12-06 09:27:38
问题 I am working on an android project and I added custom fonts on few layouts successfully. But when I tried adding them in a class which is not an activity which extends RecyclerView.ViewHolder, it creates a null pointer exception. I tried looking for but no luck. Initially I did not use context.getAssets(), I only used getAssets(). But then I was getting "cannot resolve method" on getAssets(). Since getAssets() is a part of Context, I included context and then all the errors went away. But

Firebase+RecyclerView: RecyclerView not displaying on application start

百般思念 提交于 2019-12-06 09:26:09
问题 I'm using the Android Studio provided class for a tabbed activity that uses Action Bar Tabs with ViewPager. Inside this activity, I'm trying to initialize a RecyclerView with data from a Firebase database. Problem: On the app's first run, the RecyclerView is empty as shown below. If I close and reopen the application from within the emulator, my RecyclerView gets populated as it should, as shown below. Any ideas as to why this might be happening? I have a theory but I haven't been able to

Filtering RecyclerView's list with LiveData content using SearchView

独自空忆成欢 提交于 2019-12-06 09:15:30
问题 I've created RecyclerView which contains simple list of words (String names of GroupVc objects). As list can be very long I want to make it filterable with SearchView in Toolbar. Architecture of my application is based on Android Architecture Components, where all GroupVc objects exist in Room database and access to DataBase from UI is provided through ViewModel and Repository objects. I'm filing my RecyclerView with list of all GroupsVc wrapped in LiveData to keep it updated. My problem is

How to add a Onclick listener on a RecyclerView in Android Studio with Kotlin?

强颜欢笑 提交于 2019-12-06 08:20:57
so I want to have a onclicklistener for my RecyclerView in Android but I am not sure how I should do that. I have a CustomAdapterClass for my Workoutlist that looks like this: class CustomAdapter(val workoutList: ArrayList<workout>) : RecyclerView.Adapter<CustomAdapter.ViewHolder>() { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomAdapter.ViewHolder { val v = LayoutInflater.from(parent.context).inflate(R.layout.list_layout, parent, false) return ViewHolder(v) } override fun onBindViewHolder(holder: CustomAdapter.ViewHolder, position: Int) { holder.bindItems

RecyclerView onBindViewHolder is called too many times for one cell

旧街凉风 提交于 2019-12-06 08:02:37
问题 I am using RecyclerView with GridLayoutManager. For each item in the grid, I need to call a REST api to retrieve data. Then, after get data asynchronously from remote,I use UIL to load/display image. Everything seems to be fine. But i find onBindViewHolder is called too too too many times for specific items. logcat log Talk is cheap, let me show you the code: @Override public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) { EditCourseImageAttachmentHolder holder =

RecyclerView BackgroundColor

≯℡__Kan透↙ 提交于 2019-12-06 07:59:40
问题 I used a RecyclerView to display some text data. I got the logic in it to select different cards. I would like to change the appearance of the selected cards. public void toggleSelection(int pos) { RecyclerView.ViewHolder viewHolder = recView.findViewHolderForPosition(pos); if (selectedItems.get(pos, false)) { selectedItems.delete(pos); viewHolder.itemView.setBackgroundColor(Color.WHITE); } else { selectedItems.put(pos, true); viewHolder.itemView.setBackgroundColor(Color.GREEN); }

Android RecyclerView -Multiple Edittext change simultaneously

无人久伴 提交于 2019-12-06 07:43:06
I have a RecyclerView that has many cards that hold 4 EditText . When I input values in one EditText of one card, it fills the same value in random cards. Surprisingly it does not jump EditText s for example: If I input values in edittext1 of card1 it would fill the same value into edittext1 in card8 and if I change the value in card8 it will change the value back in card1 . Could someone please tell me why this is happening. Thank You in Advance Here is my code: public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> { private String[] mDataset; public String[][] data = new