Hey all, first post and a noob in Android programming, but willing to learn! Basically I've taken the Google sample of a tab layout from here
I found that method to be very easy to create tabs with text within each tab, but I'm trying to make it so that when a tab is selected, I want the text listed below to be separated by a dividing line. So that a line is dividing between each paragraph, however I'm having trouble doing this. This is what I have so far: 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>
Here is the info in the java file:
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);
}
}
In main.xml I can get "this is the FIRST line of the 1st tab" on the first line, but "this is the SECOND line of the 1st tab" is showing up in the first line, and in all other tabs. Thanks in advance for any help, hopefully with my gained knowledge I can help others in the future.
If you simply want a separator (line dividing the area into two sections), you can use the following code in your layout XML file;
<View android:id="@+id/firstDivider"
android:layout_height="2dp"
android:layout_width="fill_parent"
android:background="#000080" />
The above code will produce a 2dp thick, navy blue divider.
Increasing the layout_height
will increase the thickness of divider.
Revert back for any query.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With