Clarify fragment code

This commit is contained in:
misaochan 2016-08-25 19:00:40 +12:00
parent d62fd565b6
commit f5d448285f
3 changed files with 14 additions and 8 deletions

View file

@ -7,6 +7,7 @@ import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
@ -32,11 +33,19 @@ public class NearbyActivity extends AppCompatActivity {
registerLocationManager();
// Begin the transaction
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
NearbyListFragment fragment = new NearbyListFragment();
ft.add(R.id.container, fragment);
ft.commit();
/*
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new NearbyListFragment())
.commit();
}
*/
}
@Override

View file

@ -64,12 +64,9 @@ public class NearbyListFragment extends ListFragment {
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);

View file

@ -4,10 +4,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment android:name="fr.free.nrw.commons.nearby.NearbyListFragment"
<FrameLayout
android:id="@+id/container"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent" />
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</LinearLayout>