Création séparateurs de ligne dans l'onglet mise en page Android paragraphes
Question
Salut à tous, premier poste et un noob dans la programmation Android, mais prêt à apprendre! Au fond, j'ai pris l'échantillon Google d'une mise en page d'onglet de ici
Je trouve cette méthode pour être très facile de créer des onglets avec le texte dans chaque onglet, mais je suis en train de faire en sorte que lorsqu'un onglet est sélectionné, je veux que le texte ci-dessous pour être séparés par une ligne de démarcation. Alors qu'une ligne divise entre chaque paragraphe, mais je ne parviens pas à le faire. Voilà ce que j'ai jusqu'à présent: main.xml:
<?xml version="1.0" encoding="utf-8"?>
<TableRow>
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the FIRST line of the 1st tab" />
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the SECOND line of the 1st tab" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TableRow>
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is First line of the 2nd tab" />
</TableRow>
<View
android:layout_height="2dip"
android:background="#FF909090" />
<View
android:layout_height="2dip"
android:background="#FF909090" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the First line of the 3rd tab" />
<TextView
android:id="@+id/textview4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="This is the First line of the 4th tab." />
</TableLayout>
</FrameLayout>
Voici les informations dans le fichier java:
public class HelloTabWidget extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost mTabHost = getTabHost();
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2));
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));
mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("TAB 4").setContent(R.id.textview4));
mTabHost.setCurrentTab(0);
}
}
Dans main.xml je peux obtenir «c'est la première ligne du 1er onglet » sur la première ligne, mais «c'est la deuxième ligne du 1er onglet » est apparaître dans la première ligne, et dans tous les autres onglets. Merci d'avance pour toute aide, je l'espère avec mes connaissances acquises je peux aider les autres à l'avenir.
La solution
Si vous voulez simplement un séparateur (ligne de démarcation entre la zone en deux sections), vous pouvez utiliser le code suivant dans votre mise en page fichier XML;
<View android:id="@+id/firstDivider"
android:layout_height="2dp"
android:layout_width="fill_parent"
android:background="#000080" />
Le code ci-dessus produit un 2DP épais, diviseur bleu marine.
L'augmentation de la layout_height
augmentera l'épaisseur du diviseur.
retour Revert pour toute requête.