хорошо, большое спасибо, просто изучая всю терминологию тоже.
то значит? Я боролся с этимListView
что я используюArrayAdapter
, Я написал этот замечательный фрагмент диалога, который я перезванивал в updateUI listner.ListView
У меня есть в моем фрагменте изDialogFragment
сначалаArrayAdapter
был сложный тип класса я создал:
ArrayAdapter<Location> theLocations;
...
//in oncreateview
theLocations = new ArrayAdapter<Location>(mContext, R.layout.location_row, locations);
//here locations is an ArrayList<Location>
тогда у меня есть:
public void onUIUpdate(Location l) { //called from dialog fragment
locations.add(l);
theLocations.notifyDataSetChanged();
}
то это дало вышеупомянутую ошибку, поэтому я переключил его, чтобы использовать только
String[] locationNames = new String[sizeofLocations];
theLocations=new ArrayAdapter<String>(mContext, R.layout.location_Row, locationNames );
public void onUIUpdate(Location l) {
locations.add(l);
locationNames = new String[locations.size()];
for(locations.size() etc...) {
locationNames [i] = new String(locations.get(i).getName());
}
theLocations.notifyDataSetChanged();
}
Это не ошибка в моем методе обновления (который обновляет пользовательский интерфейс), но он ничего не обновил Так что я заблудился относительно того, как обновить этот ArrayAdapter, я думал, что notifyChange должен был это сделать, но он либо ничего не делает, либо выдает вышеуказанную ошибку.
У меня нет проблем с моими SimpleCursorAdapters в других местах моей программы (пока мои курсоры остаются открытыми, и я вызываю для них запрос).
Любое понимание того, что я делаю неправильно?
По запросу здесь мой макет для R.layout.location_row
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent" android:orientation="horizontal">
<TextView android:text="@+id/TextView01" android:layout_height="wrap_content" android:id="@+id/location_name"
android:textSize="15px" android:layout_marginTop="10px" android:layout_width="wrap_content"></TextView>
<TextView android:text="|" android:layout_height="wrap_content"
android:textSize="15px" android:layout_marginTop="6px" android:layout_width="wrap_content"></TextView>
<TextView android:text="@+id/TextView01" android:layout_height="wrap_content" android:id="@+id/location_lat"
android:textSize="15px" android:layout_marginTop="6px" android:layout_width="wrap_content"></TextView>
<TextView android:text="|$" android:layout_height="wrap_content"
android:textSize="15px" android:layout_marginTop="6px" android:layout_width="wrap_content"></TextView>
<TextView android:text="@+id/TextView01" android:layout_height="wrap_content" android:id="@+id/location_lon"
android:textSize="15px" android:layout_marginTop="6px" android:layout_width="wrap_content"></TextView>
</LinearLayout>