Error: No se puede resolver notifyDataSetChanged (); Androide

Estoy teniendo algunos problemas con la actualización de mi ListView.

Así que use notifyDataSetChanged (); Pero dice que no se puede resolver.

Aquí está la parte del código que no funciona:

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_activity2); background2= (RelativeLayout) findViewById(R.id.background); final ListView theListView = (ListView) findViewById(R.id.listView); Intent calledActivity=getIntent(); final List pe=calledActivity.getExtras().getStringArrayList("Caller1"); String []s =new String[pe.size()]; for(int i=0;i<pe.size();i++) { s[i]=(String)pe.get(i); } final ListAdapter theAdapter= new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, pe); theListView.setAdapter(theAdapter); final int cnt=1; theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String s1 = String.valueOf(parent.getItemAtPosition(position)); pe.remove(s1); runOnUiThread(new Runnable() { public void run() { theAdapter.notifyDataSetChanged(); } }); } }); } 

notifyDataSetChanged no es un método de ListAdapter , sino de BaseAdapter , (ArrayAdapter es una subclase de BaseAdapter). Para solucionarlo, simplemente puede emitir el ListAdapter

 theListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String s1 = String.valueOf(parent.getItemAtPosition(position)); pe.remove(s1); ((BaseAdapter)theAdapter).notifyDataSetChanged(); 
  • Cómo evitar la renovación de las celdas al llamar a notifyDataSetChanged () para PinterestLikeAdapterView?
  • NotifyDataSetChanged () no funciona con mi adaptador para gridview
  • NotifyDataSetChanged- RecyclerView -¿Es una llamada asincrónica?
  • NotifyDataSetChanged no puede actualizar ListView
  • Android ParseQueryAdapter notifyDataSetChanged no funciona
  • NotifyDataSetChange no funciona desde un adaptador personalizado
  • ¿Por qué no "notifyDatasetChanged ()" notifica todos los elementos visibles?
  • Android: detecta si un ListView tiene la barra de desplazamiento (después de configurar nuevos datos)
  • Hace notificydatasetchanged llamada onCreateViewHolder al usar RecyclerView
  • Cómo actualizar algunos datos en un ListView sin utilizar notifyDataSetChanged ()?
  • Cómo añadir sugerencias dinámicamente a autocompletetextview con preservar el estado de los caracteres
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.