Ich möchte dieses XML in Java in meiner Hauptaktivität übersetzen, die Ausgabe ist Navigationsschublade. Ich brauche nur Hilfe in diesem Teil, ich habe die restlichen Teile erledigt.So erstellen Sie DrawerLayout programmgesteuert
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<FrameLayout
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
<ListView
android:id="@+id/drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#FFF"
android:choiceMode="singleChoice"/>
Ich möchte über XML in Java-Code schreiben, wie?
Vielen Dank im Voraus
aktualisieren
final DrawerLayout drawer = new android.support.v4.widget.DrawerLayout(this);
final FrameLayout fl = new FrameLayout(this);
fl.setId(CONTENT_VIEW_ID);
final ListView navList = new ListView (this);
drawer.addView(fl, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
drawer.addView(navList);
setContentView(drawer);
Ich brauche etwas Hilfe Listenansicht des Layoutbreite und das Layout der Schwerkraft im Code anpassen.
Was ist mit der Verwendung des XML-Layouts passiert? – gunar
Ich möchte es in Code erstellen, ich bin nicht interessant in XML – user289175