Moved adapter setup to onViewCreated, to prevent crash

This commit is contained in:
misaochan 2016-08-25 18:56:39 +12:00
parent b7d0e6e725
commit d62fd565b6
4 changed files with 16 additions and 3 deletions

View file

@ -6,6 +6,7 @@ import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;

View file

@ -59,15 +59,25 @@ public class NearbyListFragment extends ListFragment {
ViewGroup root = (ViewGroup) view.getRootView();
root.addView(progressBar);
*/
return view;
}
// This event is triggered soon after onCreateView().
// Any view setup should occur here. E.g., view lookups and attaching view listeners.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
// Setup any handles to view objects here
// EditText etFoo = (EditText) view.findViewById(R.id.etFoo);
final ListView listview = (ListView) view.findViewById(R.id.listview);
mAdapter = new NearbyAdapter(getActivity(), places);
//setListAdapter(mAdapter);
listview.setAdapter(mAdapter);
return view;
}
private static List<Place> loadAttractionsFromLocation(final LatLng curLatLng) {
List<Place> places = NearbyPlaces.get();

View file

@ -3,9 +3,11 @@
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="fr.free.nrw.commons.nearby.NearbyListFragment"
android:id="@+id/container"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
</LinearLayout>

View file

@ -9,5 +9,5 @@
android:id="@+id/listview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>