Notificación de AndroidDataSetChanged () no funciona
Frecuentes
Visto 156 equipos
-1
I am working on ArrayAdapter and ListView. I have an Activity A y actividad B. Activity A starts an Activity B (startActivityForResult()
) and when Activity B is finished, it returns the result back to Activity A.
Actividad A:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home);
listViewPrayerList = (ListView) findViewById(R.id.listView_prayerlist);
prayerList = new ArrayList<PrayerSetting>();
if (getIntent().hasExtra(Utils.PRAYER_LIST)) {
prayerList.clear();
prayerList.addAll((ArrayList<PrayerSetting>) getIntent()
.getSerializableExtra(Utils.PRAYER_LIST));
pAdapter = new PrayerAdapter(this, R.layout.prayer_list_item,
prayerList);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (data != null && data.hasExtra(Utils.SETTINGS)) {
PrayerSetting p = (PrayerSetting) data
.getSerializableExtra(Utils.SETTINGS);
prayerList.set(itemClickedPosition, p);
pAdapter.notifyDataSetChanged(); // UI/List doesn't change
}
}
I don't understand what I am doing wrong! I have tried many solutions but still don't get it.
- Stackoverflow Question 1
- Stackoverflow Question 2
- Stackoverflow Question 3
- Blogspot link
- Stackoverflow Question 4
I do understand that its a basic question. Thanks in Advance.
1 Respuestas
-1
Intenta moverte
pAdapter = new PrayerAdapter(this, R.layout.prayer_list_item,
prayerList);
before if statement in onCreate
contestado el 28 de mayo de 14 a las 13:05
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android android-arrayadapter or haz tu propia pregunta.
how are you setting the adapter? please post - Syed Waqas
listView.setAdapter(pAdapter); - Faizan Mubasher
can you please post complete code i.e. adapter initializing and your custom adapter - Syed Waqas
Is it data really changed? - betorcs
Try re-setting the adapter. I've had this issue before and this worked. - liarspocker