Что это значит?Я боролся с этим ListView
, который у меня есть ArrayAdapter
.Я написал этот замечательный фрагмент диалога, который я перезваниваю в listU updateUI, потому что я хочу обновить 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>