android-adapter

Populate listview after the addition of database

馋奶兔 提交于 2019-12-02 18:07:28
问题 I have an app which displays data in a fragment(uses webservice). After login, fragment fetches data from json and add to database, after that I want to populate it in my fragment. My fragment shows nothing after adding database. public class GridFragment extends Fragment { Context mContext; GridView gridd; GridAdapter adapter; MagazineGetIssues mgi; ArrayList<DataVal> Issues = new ArrayList<>(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

FragmentPagerAdapter notifyDataSetChanged not working

谁都会走 提交于 2019-12-02 17:56:01
I got a FragmentPagerAdapter. It's getItem method can return a fragment according to data it has from the outside. After I update the data its suppose to display I call notifyDataSetChanged and yet nothing happened. I DID override the getItemPosition method to return POSITION_NONE : public static class TabsAdapter extends FragmentPagerAdapter implements TabHost.OnTabChangeListener, ViewPager.OnPageChangeListener { private final Context mContext; private final TabHost mTabHost; private final ViewPager mViewPager; private final ArrayList<TabInfo> mTabs = new ArrayList<TabInfo>(); private

How to properly handle screen rotation with a ViewPager and nested fragments?

瘦欲@ 提交于 2019-12-02 17:40:28
I've got this activity, which holds a fragment. This fragment layout consists of a view pager with several fragments (two, actually). When the view pager is created, its adapter is created, getItem gets called and my sub fragments are created. Great. Now when I rotate the screen, the framework handles the fragment re-creation, the adapter is created again in my onCreate from the main fragment, but getItem never gets called , so my adapter holds wrong references (actually nulls) instead of the two fragments. What I have found is that the fragment manager (that is, the child fragment manager)

RecyclerView onBindViewHolder only called when getItemViewType changes

你说的曾经没有我的故事 提交于 2019-12-02 17:32:36
I have a viewholder with multiple viewtypes. When scrolling onBindViewHolder is only called when getItemViewType changes value. This causes my list items to not be updated properly. Is this a bug? Or I'm i doing something wrong here. This seems very strange behaviour from the new recyclerView class. Here is my adapter: package se.davison.smartrecycleradapter; import android.content.Context; import android.support.v7.widget.RecyclerView; import android.util.Log; import android.util.SparseIntArray; import android.view.LayoutInflater; import android.view.ViewGroup; import java.util.ArrayList;

How to get the List size() from adapter and update Activity UI from recycler Adapter itself?

吃可爱长大的小学妹 提交于 2019-12-02 13:23:30
I have a delete button in my adapter call and when i press the delete button i want to 1. remove the value from list and, 2. Update the size of the list in the main activity and . Have tried using Interface where i referred here but it's not working and i am so confused. So can any one provide me an best way My Adapter Code: @Override public void onBindViewHolder(final AddLineItem_Adapter.ViewHolder holder, final int position) { final AddLineItem_ListView addLineItem_listView = addLineItem_listViews.get(position); holder.tv_OrderID.setText(addLineItem_listView.getItemID()); holder.tv

App crashes onPlaying audio in Adapter of listview second time

岁酱吖の 提交于 2019-12-02 13:06:35
问题 My class consists of listview which contains list of tracks .Each list item consists of button Play and Pause.It should play track on clicking play and stop track on clicking pause.i am not using different buttons....i am using one button only which changes its text on clicking b/w play and pause and function accordingly. I am facing following issues- Clicking on play does play the track but when i stop the track by clicking pause and then try to play any track app crashes and shows following

How to clear ListView on Fragment when back button pressed?

旧街凉风 提交于 2019-12-02 11:17:37
问题 All data from that ListView is provided by a CursorAdapter . Whenever I pressed back button and return to activity, then click on the activity to start my fragment , all previous data still there stacking on top of each other. 回答1: Make public a method in fragment which will clear your list and call that method from its parent activity's On onBackPressed using fragment's instance. 回答2: 1) Create an interface BackPressedListener : public interface BackPressedListener { void onBackPressed(); }

TreeMap to ListView in Android

懵懂的女人 提交于 2019-12-02 09:57:07
I am making a checklist type app in Android, in which I am populating items in a list view with a check box next to them. when a user clicks on an item I want it to strike out the text and update the entry in the database for the relevant column. For this reason I am storing Name-Value pairs in a TreeMap. Where Name corresponds to the Database Column Name and Value to the value in that Column name. I have achieved this using the following: if ((c.getString(c.getColumnIndexOrThrow("Field130"))).length() > 3) { String D11 = c.getString(c.getColumnIndexOrThrow("Field130")); map.put("Field130",

Volley Plus OutOfMemoryError in List Adapter

被刻印的时光 ゝ 提交于 2019-12-02 09:19:23
I am using Volley Plus library. I am showing ListView with image and text view with no error, but when i scroll up and down lots of time in this listview it get OutOfMemoryError and crash the application. Here is LogCat : java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again at java.lang.Thread.nativeCreate(Native Method) at java.lang.Thread.start(Thread.java:1063) at com.android.volley.RequestQueue.start(RequestQueue.java:135) at com.android.volley.cache.plus.SimpleImageLoader.newRequestQueue(SimpleImageLoader.java:353) at com.android.volley.cache.plus.SimpleImageLoader.

How to clear ListView on Fragment when back button pressed?

假如想象 提交于 2019-12-02 04:41:24
All data from that ListView is provided by a CursorAdapter . Whenever I pressed back button and return to activity, then click on the activity to start my fragment , all previous data still there stacking on top of each other. Make public a method in fragment which will clear your list and call that method from its parent activity's On onBackPressed using fragment's instance. HaroldSer 1) Create an interface BackPressedListener : public interface BackPressedListener { void onBackPressed(); } 2) In your activity, you can override onBackPressed() : @Override public void onBackPressed() { List