88425

Can't get method notifydatasetchanged

Question:

the context : i have 2 class, a class Listactivity and another class AudioListActivity in wich i have define a custom arrayadapter. So in the ListActivity with oncreate, i call once my custom arrayadapter with setListAdapter ( MyListAdapter = new .... ) to populate my listview with 10 items. It works well. My problem is that on an onclick, in listactivity : 1/ i call a thread to reload an array with 10 others items ( works well ) 2/ i want to refresh my listview with this array ( without setListAdapter again because i don t want to create another adapter object in memory ). So i have think to notifydatasetchanged(). But when i try MyListAdapter. "completion" it doesn't give notifydatasetchanged. Then how can i do ? how can i notify my arrayadapter to refresh the listview ? need some help ! thank you !

heres Listactivity

ListView ClassListView; ListAdapter MyListAdapter; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.activity_audio); ClassListView = getListView(); ClassListView.addFooterView(footer); //chargement des données de la premiere page de la listview via LA thread threadChargeListe(0, "PremierePage", "aucun"); setListAdapter(MyListAdapter=new AudioListAdapter(this, 0, MyApplication.getMyArrayDonneesListeAudio())); //Mise en place des listeners addListener(); } private void addListener() { //listener bouton page suivante ImageButton MyPageSuivante = (ImageButton) findViewById(R.id.pagesuivante); MyPageSuivante.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { //chargement des données de la page suivante via LA thread int I = MyApplication.getMyArrayDonneesListeAudio().size(); int idref = MyApplication.getMyArrayDonneesListeAudio().get(I - 1).getIdDemandeAudio(); /* calcul de la ref de l'audio pivot */ chargeListe(idref, "PageSuivante", "aucun"); MyListAdapter. >>>>> HERE i CAN T ACCESS notifydatasetchanged ??? } });

here are first lines of my arraydapter

public class AudioListAdapter extends ArrayAdapter<DonneesListeAudio> { // Variables private Activity activity; private ArrayList<DonneesListeAudio> DataOfListView; private static LayoutInflater Inflater = null; int classPosition = 0; ViewWrapper Holder; private long classTimeHeureLecture = 0; private AsyncTask<Integer, Void, Void> MyAsynchTask; private AtomicBoolean isThreadRunnning = new AtomicBoolean(); private AtomicBoolean isThreadPausing = new AtomicBoolean(); String classAudioFileName; //Constructeur public AudioListAdapter(Activity activity, int textViewResourceId, ArrayList<DonneesListeAudio> _Liste) { super(activity, textViewResourceId, _Liste); try { this.activity = activity; this.DataOfListView = _Liste; Inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } catch (Exception e) { } } //construction de la vue de l'item public View getView(int position, View convertView, ViewGroup parent) { classPosition = position; View ItemView = convertView; try { if (convertView == null) { AND SO ON .....

Answer1:

ListAdapter has no member notifyDataSetChanged(). You have to cast your MyListAdapter to ArrayAdapter, to access it.

((ArrayAdapter<DonneesListeAudio>) MyListAdapter).notifyDataSetChanged();

check for typo

Recommend

  • Creating a button in Java, causes getLayoutParams to return null
  • How to add button in footer below listview in layout with fragment
  • Can't display list on Activity
  • How can I import an RSA private key into an RSACryptoServiceProvider?
  • JSchException: Algorithm negotiation fail diffie-hellman-group14-sha1
  • Encryption/decryption using shared key in java?
  • Improve function that converts serialized object in dot notation into js object
  • What products support 3-digit region subtags, e.g., es-419 for Latin-American Spanish?
  • Error: java.util.Arrays$ArrayList cannot be cast to java.util.ArrayList
  • onActivityResult() not called after startActivityForResult() with Intent.ACTION_GET_CONTENT
  • Store additional information during registration with Firebase in Android
  • Angular transclude in a directive containing a ng-template (generic Confirm Modal)
  • Shuffling an Array in Android
  • Where are files stored on an Android emulator?
  • using a UILocalNotification to play a sound that's not in the app bundle
  • Multiple storyboards: should I use a singleton pattern to cache them?
  • android-How to enable cache or buffering when videoView have downloaded a video
  • “[CALayer release]: message sent to deallocated instance” when dismissing modal view controller
  • Requiring gem in Rails 3 Controller failing with “Constant Missing”
  • OnItemSelectedListener for Spinner that was added programmatically does not trigger
  • How to define log4j2 path by application.properties?
  • How to send params in url query_string in Symfony?
  • Listview - list item selection and initial setting (custom made items)
  • UIScrollView setContentOffset: animated: not working
  • Automapper missing type map configuration or unsupported mapping
  • Installing libCurl - ruby 1.9.3 .. rails 3.2.12 .. Windows
  • Are there any libraries for Python to simulate keyboard action?
  • How to create a new Bundle object?
  • Creating a Multi-Step Modal Using Jquery
  • Get the number 18437736874454810627
  • allocating memory to an array of string
  • How to get listview position?
  • Pass Dictionary to Javascript array
  • Connect .sks to skscene.h
  • How to test if a URL from an Eclipse bundle is a directory?
  • How to rebase a series of branches?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Microsoft Visual Studio Community 2015 always crashes in Windows 10 if swithed to Visual FoxPro
  • Cannot Parse HTML Data Using Android / JSOUP
  • Recursive/Hierarchical Query Using Postgres