android-adapter

Better to recreate listview adapter or to clear and repopulate?

倾然丶 夕夏残阳落幕 提交于 2020-01-13 09:17:04
问题 If I have a ListView with a CustomAdapter and let's say I have this refresh() method that refreshes the list with new results, should I: Call new CustomAdapter(...) upon initialization, and every time I call refresh() , I use adapter.clear() and adapter.add(...) Call new CustomAdapter(...) every time I call refresh() Basically, I'm asking, is it better to recreate an adapter everytime I load new results or is it better to clear the results in existing adapter and add the entire list to it?

Can't set OnCheckedChangeListener to a Checkbox

血红的双手。 提交于 2020-01-10 19:09:37
问题 I am trying to set a OnCheckedChangeListener to a CheckBox but my application exits in the run time. I also tried to set listeners for my TextView and I still get the same result. Can anyone help? import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android

Can't set OnCheckedChangeListener to a Checkbox

二次信任 提交于 2020-01-10 19:08:18
问题 I am trying to set a OnCheckedChangeListener to a CheckBox but my application exits in the run time. I also tried to set listeners for my TextView and I still get the same result. Can anyone help? import android.app.ListActivity; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android

Array Adapter NotifyDataSetChanged() NullPointerException Android

落花浮王杯 提交于 2020-01-07 02:51:09
问题 I am adding a map to a list and then refreshing the array adapter. This was working perfectly earlier, but now that I am using an addItem() method from two different methods, it throws a NullPointer. I hope my code will clear up what I am saying: SimpleAdapter adapter; List<HashMap<String, String>> painItems = new ArrayList<HashMap<String, String>>(); ListView listthings; int[] to; String[] from; String painLevelString, timeOfPainString, textTreatmentString, painLocation, row1, row2, name;

How to Call AsyncTask from Adapter class?

末鹿安然 提交于 2020-01-06 20:24:15
问题 i have activity class with GetMembersAsyncTask . Also i have one Adapter class with DeleteAsynccTask . When i click cancel image in list View item then DeleteAsynccTask will call. If that item deleted successfully then i will call GetMemberAsynacTask inside OnPostExecute() method in DeleteAsynccTask . public class AddmemberSearch extends Activity { private ListViewAdapter listviewAdapter; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R

Having trouble restoring state on listview

核能气质少年 提交于 2020-01-06 19:57:28
问题 I have an app that allows the user to select an option and a certain list is displayed in a listview. I'm having issues with getting it to save and restore state. I have a list_mode that gets set depending on which option the user selects. so far I have it saving the state of the adapter but restoring it is causing an issue ( I know it's saving because when I examine customAdapter.onRestoreInstanceState(savedInstanceState) in the onCreate it's showing the right items based on selection but I

Android ListView with section headers and footers?

牧云@^-^@ 提交于 2020-01-06 08:12:10
问题 I want create the custom list to inflate the different data for each row by grouping the data I managed to get each section headers by the type of Data but I want to add the footer for each section as well. I don't know how to execute it I tried to return the section footer by getitemviewtype() but it has to be return in everyitem type so don't know how to execute it public override View GetView(int position, View convertView, ViewGroup parent) { programTabAllItemHolder

How to use ParseObjects with a RecyclerView?

泪湿孤枕 提交于 2020-01-06 04:56:12
问题 I am attempting to pull data from my parse server and display an image and text within a RecyclerView of CardViews. I have encountered a few issues, some of which may not have been corrected appropriately, so please feel free to correct any novice code you find below outside of my two current issues. Finally my two issues are. The data does not display initially. I have 3 tabs in a ViewPager and I have to swipe over twice in order for it to display. If I'm on tab 1 the data doesn't appear

With androidx.appcompat library FirebaseRecyclerAdapter not working

北慕城南 提交于 2020-01-06 01:54:27
问题 When upgrading build tool version and target SDK version to API 28 we have to use new support libraries with androidx prefix. I have replaced all libs with new libs here they are // Libs for newer API 28 implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.1.0-alpha01' implementation 'androidx.cardview:cardview:1.0.0' Now FirebaseRecyclerAdapter from the import below, asking

Implementing an RecycleView or CardView items with the same design for eachother

萝らか妹 提交于 2020-01-05 02:55:36
问题 I need to know, when the user clicking on one item(or for example, whatsApp contacts) WhatsApp showing to the user one design with this picture example: here is the recycle view items: and i'm using : http://code.tutsplus.com/tutorials/getting-started-with-recyclerview-and-cardview-on-android--cms-23465 Main-activity: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout