android-adapter

PagedListAdapter Not Using DiffUtil On invalidate Data

馋奶兔 提交于 2020-01-23 06:42:28
问题 Every time I call invalidate data my DIFF_UTIL is not used. The logs are not shown and the entire list is updated with new data causing the screen to move positions etc. Not sure what the issue is here. I have PagedListAdapter with a LiveData<PagedList<Post>> postList and I call postList.getValue().getDataSource().invalidate(); to refresh my data. I have DIFF_UTIL public static DiffUtil.ItemCallback<Post> DIFF_CALLBACK = new DiffUtil.ItemCallback<Post>() { @Override public boolean

How to reset recyclerView position item views to original state after refreshing adapter

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-22 16:43:06
问题 I have a RecyclerView with rows that have views that when clicked will be disabled for that row position. The problem is after I update the adapter like this: adapterData.clear(); adapterData.addAll(refreshedAdapterData); notifyDataSetChanged(); After refreshing the data, the disabled views at the previous recycler position still remain disabled even though the data is refreshed. How can I reset the views to the original state after refreshing adapter data. 回答1: Use below code. adapterData

notifyDataSetChanged after configuration change

给你一囗甜甜゛ 提交于 2020-01-22 15:56:29
问题 I'm doing some test after change device configuration (change language, orientation, etc), and i notice that after this, the method "notifyDataSetChanged()" is not working. The action example: I'm calling updateList() everytime i do an action like delete, save, etc. The user click a delete button, a DialogFragment is shown, "Are you sure you want to delete?", when i change the orientation, or the language, or any configuration of the device and then click "yes" on the Dialog, the data is

Copy to clipboard the content of a cardview

耗尽温柔 提交于 2020-01-20 09:35:13
问题 I've implemented a recycler card view and want to use a button click method to copy the content of cardView. There aretwo texts in cardview and i want to copy the content only, different for different cards. How can I do this? Here is my Cardview adapter. public static class ViewHolder extends RecyclerView.ViewHolder{ Button copyButton; Button shareButton; TextView title; TextView content; public ViewHolder(View itemView) { super(itemView); this.title = (TextView)itemView.findViewById(R.id

How to pass model type lists using intents from the adapter to another activity

落花浮王杯 提交于 2020-01-17 01:18:06
问题 I have a Department list that contains the department names, for example, Mens, Ladies, etc. Now if suppose, I click on 'Ladies', the next screen should be displayed with the categories list that are correlated to the Department Ladies . With my present code, only the first item on the category list is displayed. This is my code for my Department Adapter: public class Department_Adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public static Context context; private ArrayList

Implement view clicks on multiple ViewHolder types in RecycleView adapter

妖精的绣舞 提交于 2020-01-16 18:10:07
问题 I am implementing multiple ViewHolders as suggested in this answer which uses an abstract bind() . My current Adapter and ViewHolder looks likes: // MyAdapter.java {adapter code} public static abstract class MyViewHolder extends RecyclerView.ViewHolder { public MyViewHolder(View itemView) { super(itemView); } protected abstract void bind(MyModel item); } // ViewHolder1.java public class ViewHolder1 extends MyAdapter.MyViewHolder implements View.OnClickListener { TextView textView; public

Android - ListView item style fails when scrolling

只谈情不闲聊 提交于 2020-01-16 12:08:08
问题 I have an issue with my ListView . I use them in several projects and the error occurs in every one of them. In one case every item has a unique image, in the other case some items contain bold text, some don't. When I scroll the images/bold texts are not in the right position and when I scroll quickly up and down again at some point (in case b ) nearl all items are bold. The only post I could find was this one but it didn't solve the issue. Here's my custom adapter: private class MyAdapter

Get filtered array size in AutoCompleteTextview

心已入冬 提交于 2020-01-14 19:22:05
问题 I am working on the project in which user can search data. For that, I have implemented AutoCompleteTextView . autoComplete.setAdapter(new ArrayAdapter<String>(CheckRiskActivity.this, R.layout.auto_text_row, druglist)); autoComplete.setThreshold(1); //druglist is my arraylist Text change listener is as below: autoComplete.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { // here I want to get the size of filtered array list every time when the

Images loading randomly into view pager with Glide and SimpleTarget

邮差的信 提交于 2020-01-14 10:36:09
问题 I'm using Glide to load image into a ViewPager using an PagerAdapter . When I load the images using the following method: Glide.with(mContext).load(mImage).placeholder(R.drawable.placeholder).into(mImageView); Everything works fine, but now I need to get the bitmap from glide and store it in a map when it loads for future edit, so I switched this method to the following one: Glide.with(mContext).load(mImage).asBitmap().placeholder(R.drawable.placeholder).into(new SimpleTarget<Bitmap>() {

How to use SparseArray as a source for Adapter?

此生再无相见时 提交于 2020-01-14 09:35:08
问题 I have a sparse array of values which I want to populate in a Spinner, and when the item is selected, I want to get the id (which is the key from the sparse array). What is the preferred way of creating an adapter from a SparseArray? Is it possible to subclass an existing Adapter like BaseAdapter or ListAdapter So that the items will have a key from the SparseArray as item id? Not knowing how to achieve the above, I am thinking of creating a simple ArrayAdapter instance and giving it values