Drawerlist Markierter Einträg ändern

kukuk

kukuk

App-Anbieter (kostenlos)
29
Hallo alle zusammen, ich bin gerade dabei mich in das Thema Fragmente einzuarbeiten und stoße aktuelle vor noch einigen Schwierigkeiten meine App von normalen Activity's auf Fragmente umzustellen. Ich rufe vom HomeFragment das Fragment UerbstundenFragment auf. Jetzt habe ich das Problem, das die DrawerList die markierten Eintrag nicht verändert, da diese Funktion nur über die MainActivity durchgeführt wird. Ich habe jetzt versucht in der onCreateView von UeberstundenFragment folgendes zu machen:
mDrawerList = (ListView) rootView.findViewById(R.id.list_slidermenu);
mDrawerList.setItemChecked(position, true);
mDrawerList.setSelection(position);

Leider funktioniert das nicht. Kann mir einer weiterhelfen, wie ich von einem Fragment aus die mDrawerList "bearbeiten" kann?

Hatte jetzt schon überlegt mir auf der MainActivity einen Timer zu bauen, der eine Variabel überprüft und sobald diese true ist, dann die markierung setzt! Aber es muss doch eine einfachere Möglichkeit dafür geben?

Sowas ?
MainActivity.mDrawerList.setSelection(1, true);


Ich habe eine Lösung gefunden ^^. Ich habe die ganzen Verweise nach Global.java verschoben und kann nun von überall auf den Drawer zugreifen!

public static DrawerLayout mDrawerLayout;
public static ListView mDrawerList;
public static ActionBarDrawerToggle mDrawerToggle;

// nav drawer title
public static CharSequence mDrawerTitle;

// used to store app title
public static CharSequence mTitle;

// slide menu items
public static String[] navMenuTitles;
public static TypedArray navMenuIcons;

public static ArrayList<NavDrawerItem> navDrawerItems;
public static NavDrawerListAdapter adapter;
 
Zuletzt bearbeitet:
Versuche es mal im Fragment mit:

MainActivity mainActivity = (MainActivity) getActivity();
mainActivity.mDrawerList.setSelection(1, true);

Und entferne bitte überall static. Java ist eine objektorientierte Sprache, deren wichtigstes Konzept die Kapselung von Code ist. Am besten Du beschäftigst Dich ein bisschen mit den Grundlagen der OPP.
 
  • Danke
Reaktionen: kukuk und swa00
Ich danke dir für deine Hilfe. Ich habe es jetzt hinbekommen.

Jetzt stehe ich vor dem nächsten Problem. Ich möchte von der MainActivity eine Funktion aus dem Fragment aufrufen.
Leider führt der Code zu einer NullPointerException. Die Funktion switch_überstunden() aus dem Fragment UeberstundenFragment greift auf das Layout des Fragmentes zu. Selbst bei einer leeren Funktion kommt es zu einer NullPointerException
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.arbeitszeit_kalkulator_pro.UeberstundenFragment.switch_überstunden()' on a null object reference

FragmentManager fm = getFragmentManager();
UeberstundenFragment fragment = (UeberstundenFragment) fm.findFragmentById(R.id.Ueberstunden_Layout);
fragment.switch_überstunden();
 
Zuletzt bearbeitet:
Wie sieht das xml aus (der Activity)?

Wenn du die support library benutzt, muss du
getSupportFragmentManager().findFragmentById(R.id.Ueberstunden_Layout);
benutzen
 
XML:
Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/Ueberstunden_Layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000100"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
     >


public class MainActivity extends Activity
public class UeberstundenFragment extends Fragment

getSupportFragmentManager kann ich nicht verwenden, wird rot dargestellt.
Der Fehler tritt weiterhin auf.......

Ich will von Activity -> FragmentFunktion zugreifen!
 
Zuletzt bearbeitet:
Der Fehler liegt im XML. Dort muss statt RelativeLayout fragment stehen. Sonst findet Android das Fragment nicht, bzw die Funktion findFragmentById() liefert null zurück.

Code:
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/Ueberstunden_Layout"
    ...
/>
 
Sorry das ich nochmal nachfragen muss. Aber ich komm einfach nicht weiter :(

Wenn ich in der datei fragment_ueberstunden.xml von relativeLayout auf fragment umändere, lässt sich dieses fragment nicht mehr laden und stürzt ab. Wenn ich wieder auf RelativeLayout wechsele wird das Fragment wieder eingeblendet.

fragment_ueberstunden.xml:

Code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/Ueberstunden_Layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000100"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"

>


    <ScrollView
        android:id="@+id/layout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:scrollbarStyle="outsideInset"
        android:scrollbars="horizontal|vertical" >

        <HorizontalScrollView
            android:id="@+id/horizontalView"
            android:layout_width="wrap_content"
            android:layout_height="438dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"

            android:scrollbars="horizontal|vertical" >

            <TableLayout
                android:id="@+id/TableLayout_uberstunden"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                >

                <TableRow
                    android:id="@+id/tableRow1"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <TableLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                        <TableRow
                            android:id="@+id/tableRow17"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent" >

                            <TextView
                                android:id="@+id/textView001"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:text="@string/ausgewaehltes_datum"
                                android:textColor="#FFFFFF" />

                            <TextView
                                android:id="@+id/textView7"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="TextView"
                                android:visibility="invisible" />

                            <Button
                                android:id="@+id/textView5"
                                android:layout_width="wrap_content"
                                android:layout_height="40dp"
                                android:clickable="true"
                                android:onClick="OnClick"
                                android:text="@string/zero"
                                android:textColor="#000100" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow18"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow19"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow20"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow21"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/textView4"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:text="@string/ueberstunden_anzahl"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow22"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow23"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow24"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow25"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <EditText
                                android:id="@+id/editText1"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:background="@layout/custom_edittext"
                                android:textCursorDrawable="@drawable/color_cursor"
                                android:digits="0123456789"
                                android:ems="10"
                                android:singleLine="true"
                                android:hint="@string/std"
                                android:inputType="numberDecimal"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow26"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow27"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow28"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow29"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/TextView02"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:text="@string/ueberstunden_minuten"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow30"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow31"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow32"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow33"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <EditText
                                android:id="@+id/EditText3"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:background="@layout/custom_edittext"
                                android:digits="0123456789"
                                android:ems="10"
                                android:singleLine="true"
                                android:textCursorDrawable="@drawable/color_cursor"
                                android:hint="@string/min"
                                android:inputType="numberDecimal"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow34"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow35"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow36"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow37"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/TextView03"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:text="@string/zeit_der_gemachten_ueberstunden"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow38"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow39"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow40"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow8"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" >

                    <TableLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                        <TableRow
                            android:id="@+id/tableRow41"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent" >

                            <EditText
                                android:id="@+id/EditText4"
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:layout_marginLeft="10dp"
                                android:singleLine="true"
                                android:background="@layout/custom_edittext"
                                android:layout_weight="1"
                                android:maxLength="31"
                                android:hint="@string/zeitraum"
                                android:textCursorDrawable="@drawable/color_cursor"
                                android:inputType="text"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow42"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow43"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow44"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow45"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/TextView01"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:text="@string/bemerkungen"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow46"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow47"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow48"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" >

                        <TableRow
                            android:id="@+id/tableRow49"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent" >

                            <EditText
                                android:id="@+id/EditText2"
                                android:layout_width="wrap_content"
                                android:layout_height="match_parent"
                                android:layout_marginLeft="10dp"
                                android:background="@layout/custom_edittext"
                                android:layout_weight="1"
                                android:hint="@string/bemerkungen_textview"
                                android:singleLine="true"
                                android:inputType="text"
                                android:maxLength="31"
                                android:textCursorDrawable="@drawable/color_cursor"
                                android:textColor="#FFFFFF" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow50"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow51"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow52"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow13"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow15"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <Spinner
                                android:id="@+id/spinner4"
                                android:layout_width="225dp"
                                android:layout_height="wrap_content"
                                android:layout_marginTop="10dp"
                                android:layout_marginLeft="5dp"

                                android:background="@drawable/custom_spinner" />

                            <ImageView
                                android:id="@+id/ImageView2"
                                android:layout_width="25dp"
                                android:layout_height="25dp"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="30dp"

                                android:src="@drawable/pencil_selector" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow16"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/textView6"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="TextView"
                                android:visibility="invisible" />
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow61"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow62"
                            android:layout_width="wrap_content"

                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/textView13"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:textColor="#FFFFFF"
                                android:text="Überstunden-Farbe: " />

                            <TextView
                                android:id="@+id/textView16"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="TextView"
                                android:visibility="invisible" />

                            <Button
                                android:id="@+id/button1"

                                android:layout_width="170px"
                                android:layout_height="125px"
                                android:onClick="colorpicker_öffnen"
                                android:background="@drawable/no_color" />

                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow63"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow64"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow65"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>

                </TableRow>

                <TableRow
                    android:id="@+id/tableRow66"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TextView
                        android:id="@+id/textView15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="TextView"
                        android:visibility="invisible" />

                </TableRow>

                <TableRow
                    android:id="@+id/tableRow11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow53"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/textView12"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="a"
                                android:visibility="invisible" />

                            <ImageView
                                android:id="@+id/imageView1"
                                android:layout_width="50dp"
                                android:layout_height="50dp"
                                android:onClick="werte_berechnen"
                                android:src="@drawable/add_selector" />

                            <TextView
                                android:id="@+id/textView8"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="TextView"
                                android:visibility="invisible" />

                            <TextView
                                android:id="@+id/textView9"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="TextViewwwi"
                                android:visibility="invisible" />

                            <ImageView
                                android:id="@+id/imageView2"
                                android:layout_width="50dp"
                                android:layout_height="50dp"
                                android:onClick="abbrechen"
                                android:src="@drawable/cancel_selector" />
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow54"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow55"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow56"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TableLayout
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" >

                        <TableRow
                            android:id="@+id/tableRow57"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >

                            <TextView
                                android:id="@+id/textView3"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_marginLeft="10dp"
                                android:layout_marginTop="10dp"
                                android:text="@string/anzahl_der_ueberstunden"
                                android:textColor="#FFFFFF" />

                            <TextView
                                android:id="@+id/textView11"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:text="textvie"
                                android:visibility="invisible" />

                            <TextView
                                android:id="@+id/textView2"
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"

                                android:layout_marginTop="10dp"
                                android:text="@string/hours"
                                android:textColor="#FFFFFF" />

                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow58"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow59"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>

                        <TableRow
                            android:id="@+id/tableRow60"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content" >
                        </TableRow>
                    </TableLayout>
                </TableRow>

                <TableRow
                    android:id="@+id/tableRow14"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="TextView"
                        android:visibility="invisible" />
                </TableRow>

            </TableLayout>
        </HorizontalScrollView>
    </ScrollView>

</RelativeLayout>



Aufruf des fragments über MainActivity:

Code:
Fragment fragment = null;
fragment = new UeberstundenFragment();
Global.aktueller_fragment = "UeberstundenFragment";


if (fragment != null) {
   android.app.FragmentManager fragmentManager = getFragmentManager();
   fragmentManager.beginTransaction()
         .replace(R.id.frame_container, fragment).commit();

   getActionBar().setTitle(mTitle);
   // update selected item and title, then close the drawer


} else {
   // error in creating fragment
   Log.e("MainActivity", "Error in creating fragment");
}

UeberstundenFragment.java on CreateView

Code:
@Override
public View  onCreateView(LayoutInflater inflater, ViewGroup container,
                 Bundle savedInstanceState) {
 
   rootView = inflater.inflate(R.layout.fragment_ueberstunden, container, false);
 

Ähnliche Themen

D
Antworten
14
Aufrufe
1.708
chrs267
chrs267
C
  • Chicken Wing
Antworten
4
Aufrufe
854
Chicken Wing
C
Vapeilas91
  • Vapeilas91
Antworten
3
Aufrufe
698
swa00
swa00
Zurück
Oben Unten