android-adapter

Fast taps (clicks) on RecyclerView opens multiple Fragments

喜欢而已 提交于 2019-12-04 08:28:31
问题 I have implemented onClick listener to my ViewHolder for my RecyclerView But when I perform very fast double taps or mouse clicks, it performs the task (opens a seperate fragment in this case) twice or three times. here is my code public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { TextView tvTitle, tvDescription; public ViewHolder(View itemView) { super(itemView); itemView.setClickable(true); itemView.setOnClickListener(this); tvTitle = (TextView)

How to fix notifyDataSetChanged/ListView problems in dynamic Adapter wrapper Android

时光毁灭记忆、已成空白 提交于 2019-12-04 08:09:15
Summary: Trying to dynamically add heading rows to a ListView via a custom adapter wrapper. ListView is having trouble keeping the scroll position in sync. Runnable demo project provided. I would like to dynamically add items to a list based on the values in a CursorAdapter, several positions ahead of what the user is currently viewing. To do this, I have an adapter that wraps the CursorAdapter and keeps the new content indexed in a SparseArray. The ListView needs to be updated when items are added to the custom adapter, but I have met a lot of pitfalls trying to get that to work and would

How to resolve \"The content of the adapter has changed but ListView did not receive a notification” exception [duplicate]

雨燕双飞 提交于 2019-12-04 06:18:58
This question already has an answer here: Android, ListView IllegalStateException: “The content of the adapter has changed but ListView did not receive a notification” 25 answers I found a lot of questions on the same topic. But I am unable to figure out what I am doing wrong here. Exception: "The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread" I have a TextWatcher to my AutoCompleteTextView. I am trying to update the dropdown list when the text changes.

How to set custom ListAdapter to list view in appwidget?

强颜欢笑 提交于 2019-12-04 04:28:43
问题 I have a listView. I needed a custom view for each list item, so I've created a custom ListAdapter which gives the views, layout for which is given below. But how do I set this listAdapter to the ListView in the widget using RemoteViews ? <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@android:color

Android: visible ListView images flicker when adding data to ArrayAdapter

谁说我不能喝 提交于 2019-12-04 04:12:51
I have a custom adapter which extends ArrayAdapter, it implements the view holder patterns to show data (text + image) from a web service. for lazy loading of the images I use the async tasks pattern from the advanced training in the Android's developers site, I also use disk + ram bitmap cache. when there is additional data to be retrieved I add a footer view that clicking on it retrieves additional data from the web service and add it to the adapter. the problem is that when this new data is being added, some of the visible images are changing and immediately changing back, which result in a

getting View for ListView item / reverse order on 2.2; works on 4.0.3

邮差的信 提交于 2019-12-04 03:37:40
问题 I have a ListView which shows items from ArrayAdapter. I want to animate the view when it is cliked. The problem is that on different versions of android I am getting different views (see below) I'm getting the view from ListActivity using this method : private View getViewForListPosition(int position) { int firstPosition = mList.getFirstVisiblePosition() - mList.getHeaderViewsCount(); int wantedChild = position - firstPosition; ZLog.d(LOG,"getViewForListPosition , position : " + position + "

Dynamically remove an item from a ViewPager with FragmentStatePagerAdapter

我们两清 提交于 2019-12-04 02:50:31
There are quite a few discussions around this topic ViewPager PagerAdapter not updating the View Update ViewPager dynamically? Removing fragments from FragmentStatePagerAdapter I have tried various solutions (including the invalidation with POSITION_NONE ) . But I still donT know how to remove an item properly. What happens is either I get a blank page (meaning the fragment is destroyed, but the instantiateItem was not called for a replacement) or the whole thing crashes probably because the way the Android manages the fragment instances do not match how I keep them in my arraylist/sparsearray

Can I set custom onClick on my timeline using fabric sdk?

邮差的信 提交于 2019-12-04 01:22:48
问题 I am creating a Twitter client using Fabric but I can not create a custom onClick. I created this custom adapter and tried to create a OnClickListener but not working. Always open in browser tweet. public class TweetAdapter extends TweetTimelineListAdapter { public ArrayList<Long> tweetIds=new ArrayList<Long>(); public TweetAdapter(Context context, Timeline<Tweet> timeline) { super(context, timeline); } @Override public View getView(int position, View convertView, ViewGroup parent) { Object

Do I need multiple viewHolders for ExpandableListView?

我怕爱的太早我们不能终老 提交于 2019-12-03 21:33:14
Am I using this viewholder wrong? I'm getting an NPE on line 165. Is there an obvious reason why that I'm missing? Do I need a group viewholder and a child viewholder if I'm using expandablelistview? I marked line 165 to try to make it easier on the eyes. Thanks a lot my expandablelistview that's getting the NPE: public class MyExpandableListAdapter extends BaseExpandableListAdapter { private Context mContext; private ArrayList<ContactNameItems> mListDataHeader; private ArrayList<Boolean> phoneNumberCheckStates; private ArrayList<String> selectedNumbers; private HashMap<String, List

notifyDataSetChanged after configuration change

夙愿已清 提交于 2019-12-03 17:09:33
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 removed, but the list doesn't update. I need to quit the activity, then go back to see the alteration.