android-adapter

RecyclerView.Adapter.notifyItemChanged() never passes payload to onBindViewHolder()

强颜欢笑 提交于 2019-11-30 11:52:42
问题 I'm trying to update a ViewHolder in a RecyclerView without rebinding the entire thing. According to the docs, I should do this by calling RecyclerView.Adapter.notifyItemChanged(int position, Object payload) , where payload is an arbitrary object that will be passed to RecyclerView.Adapter.onBindViewHolder(VH holder, int position, List<Object> payloads) , where i'll be able to update the ViewHolder. But when I try this, onBindViewHolder always receives an empty list. Between these two calls,

How do I access to ListView from the adapter

故事扮演 提交于 2019-11-30 10:53:49
I have a custom ListView with my own adapter. I'm handling the click on a Button in my ListView 's item, and I want the ListView to become invisible on this click. I have no idea how to get access to the ListView from the adapter. public class ScheduleArrayAdapter extends ArrayAdapter<ScheduleListItem> { /*...*/ @Override public View getView(int position, View convertView, ViewGroup parent) { View v = convertView; if (v == null) { LayoutInflater vi = (LayoutInflater)c.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(id, null); } final ScheduleListItem o = items.get(position);

Adapter update not visible rows

梦想与她 提交于 2019-11-30 10:03:18
问题 If you review this question Update adapter from different method you will see this answer https://stackoverflow.com/a/25632407/1270400 This answer works only with visible rows.But I have to add badge to not visible and visible rows.@pomber gave a tip but I can't understand it. How can I do this process ? I need an example. 回答1: You shouldn't try to modify the child elements of a listview directly. Instead, modify the adapter so that you display the badge based on some condition. Then,

Image GridView Inside Fragment

ぃ、小莉子 提交于 2019-11-30 09:34:47
I have just started to develop on the android platform after developing on iOS. I have looked around and I can't seem to figure it out. I am trying to have a grid view appear after a tab in the action bar is selected. The fragment is brought into view by a main activity that controls the tab bar. I think the problem may be something to do with passing context but I'm not sure. Here is my MainActivity.java . This is where the fragment is initialized and attached to the activity. It works without the code in the fragment. if (mFragment == null){ mFragment = Fragment.instantiate(mActivity, mClass

android - listview filter count

会有一股神秘感。 提交于 2019-11-30 09:04:14
So after I set the filter on my listview: //Log adapter count before filter listView.getFilter().filter(searchStr) //Log adapter count after filter What I'm trying to achieve is to get the count of the result of that filtering. Like if before there are 10 items, then I apply the filter, so now only 5 items will appear, I want to get that count "5". I've tried checking the adapter count before and after the filter with no luck. They're displaying same count (I'm using a BaseExpandableListAdapter) if I apply filter, and if I apply filter again the number changes from before (but the before and

android gallery view “stutters” with deferred image loading adapter

断了今生、忘了曾经 提交于 2019-11-30 07:32:04
I would like to create an deferred loading adapter for use with a Gallery widget. That is to say getView() returns an ImageView immediately, and later some other mechanism will asynchronously call its setImageBitmap() method. I did this by creating a "lazy" ImageView that extends ImageView . public class GalleryImageView extends ImageView { // ... other stuff here ... public void setImage(final Looper looper, final int position) { final Uri uri = looper.get(position); final String path = looper.sharePath(position); new Thread(new Runnable() { @Override public void run() { GalleryBitmap gbmp =

CursorAdapter bindView optimization

你离开我真会死。 提交于 2019-11-30 06:32:45
问题 When overriding ArrayAdapter I know is correct using a pattern like this: if(view != null){ ...create new view setting fields from data }else return view; //reuse view is correct too using this pattern with CursorAdapters? My problem is that I have a textcolor which can be red or blue according to a cursor field, so I don't want any errors like a red color on a cell which has a field needing blue color. My bindView code is something like this: if(c.getString(2).equals("red")) textView

Android Data Binding : Observable List to RecyclerView's Adapter

爱⌒轻易说出口 提交于 2019-11-30 06:13:42
Is their a way, by using the ObservableList class from the new Data Binding library and the MVVM pattern, to avoid using "notifyItem(s)..." methods from the Adapter class? Or if not what could be the simpliest way to bind an ObservableList to a RecyclerView ? Thank's for any clue ! Have a look at following implementation of the RecyclerView 's adapter: https://github.com/radzio/android-data-binding-recyclerview/blob/master/recyclerview-binding/src/main/java/net/droidlabs/mvvm/recyclerview/adapter/BindingRecyclerViewAdapter.java It automatically notifies the recycler view if the

RecyclerView.Adapter.notifyItemChanged() never passes payload to onBindViewHolder()

落花浮王杯 提交于 2019-11-30 01:35:13
I'm trying to update a ViewHolder in a RecyclerView without rebinding the entire thing. According to the docs, I should do this by calling RecyclerView.Adapter.notifyItemChanged(int position, Object payload) , where payload is an arbitrary object that will be passed to RecyclerView.Adapter.onBindViewHolder(VH holder, int position, List<Object> payloads) , where i'll be able to update the ViewHolder. But when I try this, onBindViewHolder always receives an empty list. Between these two calls, the internal list of payloads is cleared. After setting breakpoints at the source code of RecyclerView,

Is it possible to bind a TableLayout with a ArrayAdapter?

偶尔善良 提交于 2019-11-30 01:20:35
问题 Is it possible to bind a TableLayout with a ArrayAdapter? 回答1: There is no such API in the framework. You can do it manually by querying the adapter yourself. Something like this: int count = adapter.getCount(); for (int i = 0; i < count; i++) { tableLayout.addView(createTableRow(adapter.getItem(i)); // or tableLayout.addView(adapter.getView(i, null, tableLayout)); } 来源: https://stackoverflow.com/questions/5039465/is-it-possible-to-bind-a-tablelayout-with-a-arrayadapter