Wie erstellen Sie programmgesteuert DrawerLayout
Möchte ich übersetzen dieses xml an java in meiner Haupttätigkeit, der Ausgabe-navigation Schublade. Ich brauche Hilfe nur in diesem Teil, beendete ich die restlichen Teile.
<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"/>
Möchte ich schreiben, über xml in java-code, Wie ?
Vielen Dank im Voraus
Update
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 wenig Hilfe benötigen, um die Anpassung listview-layout Breite und Anordnung der Schwerkraft im code.
- Was passiert mit der XML-layout-Nutzung?
- Ich möchte es schaffen, in code, ich bin nicht interessant, in xml
InformationsquelleAutor user289175 | 2014-02-10
Schreibe einen Kommentar Antworten abbrechen
Du musst angemeldet sein, um einen Kommentar abzugeben.
(Beantwortet durch die OP in einem Frage Bearbeiten. Umgerechnet auf eine community-wiki-Antwort. Sehen Frage mit Nein Antworten, aber Problem gelöst, in den Kommentaren (oder erweitert im chat) )
Der OP schrieb: