Danke schonmal
Hier die Main:
package com.example.navigationdrawerdemoapp;
import android.os.Bundle;
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.widget.ListView;
public class NavigationDrawerMainActivity extends FragmentActivity {
private DrawerLayout myDrawerLayout;
private ListView myDrawerList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_navigation_drawer_main);
FragmentA fragmentleft = new FragmentA();
FragmentB fragmentright = new FragmentB();
FragmentTransaction transaction1 = getSupportFragmentManager().beginTransaction();
FragmentTransaction transaction2 = getSupportFragmentManager().beginTransaction();
transaction1.replace(R.id.framelayout_left, fragmentleft);
transaction2.replace(R.id.framelayout_right, fragmentright);
transaction1.commit();
transaction2.commit();
myDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
myDrawerList = (ListView) findViewById(R.id.framelayout_left);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.navigation_drawer_main, menu);
return true;
}
}
Portrait XML:
<android.support.v4.widget.DrawerLayout
xmlns:android= musste ich wegen externer Verlinkung entfernen
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="@+id/framelayout_right"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ListView
android:id="@+id/framelayout_left"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp" />
</android.support.v4.widget.DrawerLayout>
<RelativeLayout xmlns:android= Musste wegen Verlinkung entfernt werden
xmlns:tools= Musste wegen Verlinkung entfernt werden
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".NavigationDrawerMainActivity" >
<FrameLayout
android:id="@+id/framelayout_left"
android:layout_width="500dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"/>
<FrameLayout
android:id="@+id/framelayout_right"
android:layout_width="300dp"
android:layout_height="fill_parent"
android:layout_alignParentRight="true" />
</RelativeLayout>
Das Linke Fragment ist ne einfache ListView, das rechte Fragment einfach ein leeres Fragment mit nem Demo Text.
Danke für die Hilfe
— geändert am 03.03.2014, 16:14:22