0

Ich habe eine TableLayout innerhalb einer ScrollView. Ich muss zum nächsten LinearLayout (dynamisch erstellt) gehen, das innerhalb der TableView ist, indem ich auf eine Schließen-Schaltfläche klicke und zum vorherigen LinearLayout zurückkehre, indem ich auf die Zurück-Schaltfläche klicke.Wie nächsten Kind tablelayout Android

meine XML Folgen, wie ich den Tableview erschaffe:

<?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:orientation="vertical" 
    android:layout_weight="1"> 

<LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:id="@+id/myLayout" 
     android:layout_height="match_parent" 
    android:layout_weight="1"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/tb_pergunta" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="?attr/colorPrimary" 
      android:minHeight="?attr/actionBarSize" /> 

     <ScrollView 
      android:id="@+id/sv_table" 
      android:layout_height="match_parent" 
      android:scrollbars="horizontal|vertical" 
      android:layout_width="match_parent" 
      android:layout_marginTop="5dip" 
      android:scrollbarStyle="outsideInset" 
      android:fillViewport="true"> 

     <TableLayout 
      android:id="@+id/tl_principal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

     </TableLayout> 
    </ScrollView> 
</LinearLayout> 

<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_weight="14"> 

    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center_horizontal"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Ir para pergunta nº:" 
      android:id="@+id/btnProximaPergunta" 
      android:visibility="gone" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/botton_back" 
      android:id="@+id/btnBackGroupExpandable" /> 

     <EditText 
      android:layout_width="99dp" 
      android:layout_height="wrap_content" 
      android:inputType="number" 
      android:ems="10" 
      android:id="@+id/edtProximaPergunta" 
      android:textAlignment="center" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/botton_next" 
      android:id="@+id/btnNextGroupExpandable" /> 

    </LinearLayout> 
</LinearLayout> 

Wie kann ich das tun?

+0

Bessere Verwendung Fragment –

+0

Ich habe nicht verstanden. Verwenden Sie Fragment besser? Fast Hast du irgendwelche Beispiele? Danke fürs Zuhören. – WilkeGutierre

Antwort

0

Sie können jedem LinearLayout eine zufällig generierte ID geben, wie beschrieben here.

Speichern Sie diese IDs in einem Array, und Sie können sie in beliebiger Reihenfolge aufrufen.

+0

Okay. Aber wie bei ScrollView stelle ich es an die Spitze? Wenn Sie auf die Schaltfläche klicken, möchte ich den Anfang der Aktivität anzeigen. Tun Sie dies in ScrollView nicht gefunden. – WilkeGutierre

+0

// Holen Sie sich die obere Position relativ zum übergeordneten Element int top = tl_principal.getTop(); // blättern Sie zur oberen Position der Verpackung ScrollView myScrollLayout.scrollTo (0, oben); – WilkeGutierre

+0

siehe hier: http://stackoverflow.com/questions/6261958/android-how-to-scroll-scrollview-in-top – SoroushA