recycler-adapter

Calling getWidth of parent in onCreateViewHolder

☆樱花仙子☆ 提交于 2019-12-12 03:28:26
问题 Is it ok to get parent's width in onCreateViewHolder at RecyclerView adapter? Are parent's dimensions measured at that state so I don't get 0 when I call getWidth() on parent? 回答1: Yes, the parent is actually the RecyclerView . It has both a non-zero getWidth() and getMeasuredWidth() by the time onCreateViewHolder is called. Easy way to verify this is set your debugger to stop in the method and inspect the parent. parent = android.support.v7.widget.RecyclerView{d08d560 VFED..... ......ID 0,0

How to create Recyclerview adapter in android?

只愿长相守 提交于 2019-12-12 01:25:31
问题 I am using this LIB. It's working fine but I can not loading my data in adapter class. like. If i add some static data that will be added but whenever i tries to load from server that will not be added. finally i am trying with this approach. But when i calls the Brandinfo and try to add data that will be error saying colon missing etc. please tell me how i can i add data to adapter to complete this recyclerview. Thanks. My Fragment class is List<BrandInfo> mContentItems = new ArrayList

Save state of the item selected in RecyclerView when view is reused while scrolling

流过昼夜 提交于 2019-12-12 01:24:37
问题 I have created an Adapter and ViewHolder for the recyclerView. I bind the imageButton of the itemView inside the Viewholder. And have set an onClickListener inside the onBindViewHolder. Everything works as expected but the issue is now when i scroll down the list the selected state of the imageButton changes for the selected item and some of the items on the bottom of the list already appear selected. Here is the some code public class ListViewHolder extends RecyclerView.ViewHolder { TextView

FirebaseRecyclerAdapter cannot be applied to [duplicate]

有些话、适合烂在心里 提交于 2019-12-12 00:51:33
问题 This question already has answers here : firebaserecycleradapter() cannot be applied to FirebaseRecyclerAdapter (5 answers) Closed last year . code: @Override public void onStart() { super.onStart(); recyclerViewadapter=new FirebaseRecyclerAdapter<RecycleModel, UserViewHolder>(RecycleModel.class, R.layout.recycler_model, UserViewHolder.class, muserDB) { @Override protected void onBindViewHolder(@NonNull UserViewHolder holder, int position, @NonNull RecycleModel model) { } @NonNull @Override

E/RecyclerView: No adapter attached; skipping layout — when making a todo list app

坚强是说给别人听的谎言 提交于 2019-12-11 19:37:26
问题 public class ToDoAdapter extends RecyclerView.Adapter<ToDoAdapter.MyViewHolder> { Context context; ArrayList<ToDoItems> toDoItems; public ToDoAdapter(Context c, ArrayList<ToDoItems> p) { context = c; toDoItems = p; } @NonNull @Override public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) { return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.front_page_layout, viewGroup, false)); } @Override public void onBindViewHolder(@NonNull MyViewHolder

RecyclerAdapter set adapter position

瘦欲@ 提交于 2019-12-11 17:20:00
问题 We can show all records in the DB no issue. When we try to limit the items to show with a sql Select the search and the RecyclerView Adapter populates correctly. The code fails when the item is selected in the list view. The list view did not get the message about what position this record is at so the view when we navigate to the DetailActivity view from ListActivity is not the item in the ListView My question is how to manage the position variable that the Adapter is using? This code flow

how to use getTag() and setTag() in recycler view

风格不统一 提交于 2019-12-11 17:19:52
问题 I am using RecyclerView custum adapter where data is fetching from getter and setter method and there is a one issue with superHero.getStatus() i.e if there is "deleted" on that position then all the view visibility will be View.GONE otherwise all views will be show on that item. Sometime it's not working as below code condition. And another issue is when I click on button then it's effects on another views. Please check below code. And tell me what should I do for improve it. Should I used

Why layout is not attach in RecyclerView Adapter class?

牧云@^-^@ 提交于 2019-12-11 17:14:39
问题 I have the following setup for a recyclerview. Now the problem is my layout is not attached with the recyclerview adapter, meaning it is not showing when I enter the layout name in the recyclerview adapter class. fragment_service.xml <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="150dp" android:layout

clear + addAll vs re-initialise list RecyclerViewAdapter android

ぃ、小莉子 提交于 2019-12-11 16:04:58
问题 What's the different between 1 and 2: 1. public void updatePostList(ArrayList<Post> updatedPosts) { this.postList.clear(); this.postList.addAll(updatedPosts); notifyDataSetChanged(); } 2. public void updatePostList(ArrayList<Post> updatedPosts) { this.postList = updatedPosts; notifyDataSetChanged(); } For me, #1 doesn't work as calling this.postList.clear() clears updatedPosts too instead of just clearing postList and I can't understand why. 来源: https://stackoverflow.com/questions/56454443

Displaying wrong date in RecyclerView Adapter

佐手、 提交于 2019-12-11 15:46:03
问题 Here I'm showing date above messages after comparison two dates. If I show dates with each item it works fine. but when I'm trying to show Today , Yesterday and date its always showing date only. Here date is not wrong, but its something getting wrong on formatting date. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss"); try { Date current_itemDate = simpleDateFormat.parse(chatMessage.getDateTime()); DateFormat outputFormat = new SimpleDateFormat("hh:mm a");