android-recyclerview

RecyclerView java.lang.IndexOutOfBoundsException: Inconsistency detected. Invalid item position when resume from added fragment

百般思念 提交于 2019-12-08 15:44:42
问题 Can you guys help me on this here is my code to add fragment mRecyclerView.addOnItemTouchListener( new RecyclerItemClickListener(getActivity(), new RecyclerItemClickListener.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (!IsScrolling) { Fragment fragment = new ProductInfoFragment(); Bundle bundle = new Bundle(); bundle.putString("prodID", mItems.get(position).getproductID()); bundle.putString("catName", catName); fragment.setArguments(bundle);

Single Row Shows Insight RecyclerView

巧了我就是萌 提交于 2019-12-08 15:28:49
问题 I have recyclerview and it shows just single records instead of two records. I have searched many post on google and found to modify height of listview items from "match_parent " To "Wrap_Content" hence I did the same but still it shows single records. Activity Mumbai_Male <?xml version="1.0" encoding="utf-8"?> <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas

Order elements of a RecyclerView via drag and drop

六月ゝ 毕业季﹏ 提交于 2019-12-08 14:58:40
问题 I am developing an application for Android which is a RecyclerView containing LinearLayout through a list of custom items. How can you order these items using drag and drop? 回答1: Now it's very easy in Android. No need to use any third party libraries. Android now supports RecycleView drag and drop out of the box, please use the below link for details: Medium | Drag and Swipe with RecyclerView 来源: https://stackoverflow.com/questions/30300356/order-elements-of-a-recyclerview-via-drag-and-drop

How to add margins to a RecyclerView for the last element?

与世无争的帅哥 提交于 2019-12-08 14:47:02
问题 I several screens that use RecyclerView and also has a small Fragment that is on top of the RecyclerView . When that Fragment is displayed I'd like to make sure I can scroll to the bottom of the RecyclerView . The Fragment isn't always displayed. If I used margins on the RecyclerView I'd need to dynamically remove and add them when the Fragment is displayed. I could add margins onto the last item in the list, but that is also complicated and if I load more things later (ie pagination) I'd

intent put extra method is crashing the app

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 14:05:07
问题 So here is what I want to do , get the image link from Mydata, display it in image view and then send the image link via intent put extra method to webview activity and display the image in webview from that image link. The images are loading in Image Views but whenever I try to send the image_link via intent putEtra method the app is crashing on onClick method. I think something is wrong with intent.putExtra("image",my_data.get(position).getImage_link()); may be I am not getting the image

How to change selected item position to top in Recyclerview?

百般思念 提交于 2019-12-08 14:03:28
I have recyclerview in that I want to change item's position dynamically to top after selecting the item of recyclerview . Please suggest best way to achieve the above problem? You need to swap selected item with top item in list, then notify your adapter about position change. A sample code would look like: Collections.swap(orderItems.getItems(), position, 0); notifyItemMoved(position, 0); Hope it helps! Try this String Item = List.get(position); List.remove(position); // remove item from the list List.add(0,removedItem); // add at 0 index of your list notifyDataSetChanged();

Passing data on click in RecyclerView.Adapter

我是研究僧i 提交于 2019-12-08 13:29:05
问题 I have a RecyclerView on my fragment that shows certain files i've loaded from an FTP Server. I'm trying to set an onClickListener for each item, so when it will be clicked, a DialogFragment will be shown, in which the user will be able to choose whether to download or open the file. My problem is: I need to send to my dialog 2 things: The target fragment, which will download/open the file after the user chooses what to do. This can be easily dont with setTargetFragment() , the only problem

Recyclerview preview showing grey screen with android.support.v7.widget.RecyclerView in center

两盒软妹~` 提交于 2019-12-08 13:07:29
问题 I am trying to add Recyclerview to my activity layout but the layout preview shows me this. I went through all possible answers which i could find out and tried doing things like changing app theme to holo.light adding <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> to res>styles.xml went through all possible relating questions like this and this as well and made changes accordingly in my code. My build.gradle file is as follows: apply plugin: 'com.android

How implement multi view types for RecycleView?

坚强是说给别人听的谎言 提交于 2019-12-08 12:46:20
问题 Currently, I work on custom multi-view types for RecycleView. I found many solutions for this problem, but I will share my way. The different is use enum for define ViewType. See my answer for more detail. (Just want to share). 回答1: UPDATE I recommend read this article: Writing Better Adapter Here is the way I custom multi-view types for RecyclewView. I will show the code first, then explain bellow. @SuppressWarnings("unchecked") public class BaseAdapter extends RecyclerView.Adapter

How to replace gridView to RecyclerView

ぐ巨炮叔叔 提交于 2019-12-08 12:04:17
问题 I am developing an app in which my previous colleague used GridView to show data,but i want to use recyclerview with cardadapter , but I am not getting how to do that. Here is my code for mainActivity: public class ActivityCategoryList extends Activity { GridView listCategory; ProgressBar prgLoading; TextView txtAlert; // declare adapter object to create custom category list AdapterCategoryList cla; // create arraylist variables to store data from server static ArrayList<Long> Category_ID =