ProfileActivity: Add two-pane master-detail layout
This is designed for tablets, but for testing purposes, it is currently enabled for all devices in landscape orientation. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
2154306fcb
commit
2df899eae5
@ -22,6 +22,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class ProfileActivity extends Activity {
|
public class ProfileActivity extends Activity {
|
||||||
private final ServiceConnection connection = new ProfileServiceConnection();
|
private final ServiceConnection connection = new ProfileServiceConnection();
|
||||||
|
private boolean isSplitLayout;
|
||||||
private final List<ServiceConnectionListener> listeners = new ArrayList<>();
|
private final List<ServiceConnectionListener> listeners = new ArrayList<>();
|
||||||
private ProfileServiceInterface service;
|
private ProfileServiceInterface service;
|
||||||
|
|
||||||
@ -38,9 +39,12 @@ public class ProfileActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// This layout consists only of containers for fragments.
|
// This layout consists only of containers for fragments.
|
||||||
setContentView(R.layout.profile_activity);
|
setContentView(R.layout.profile_activity);
|
||||||
|
isSplitLayout = findViewById(R.id.detail_fragment_container) != null;
|
||||||
// Fill the layout with the initial set of fragments.
|
// Fill the layout with the initial set of fragments.
|
||||||
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||||
transaction.add(R.id.list_fragment_container, new ProfileListFragment());
|
transaction.add(R.id.list_fragment_container, new ProfileListFragment());
|
||||||
|
if (isSplitLayout)
|
||||||
|
transaction.add(R.id.detail_fragment_container, new PlaceholderFragment());
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
// Ensure the long-running service is started. This only needs to happen once.
|
// Ensure the long-running service is started. This only needs to happen once.
|
||||||
final Intent intent = new Intent(this, ProfileService.class);
|
final Intent intent = new Intent(this, ProfileService.class);
|
||||||
|
19
app/src/main/res/layout-land/profile_activity.xml
Normal file
19
app/src/main/res/layout-land/profile_activity.xml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:baselineAligned="false"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/list_fragment_container"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/detail_fragment_container"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="2" />
|
||||||
|
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user