質問

ちょっと、最初の投稿とAndroidプログラミングのNoobですが、喜んで学ぶことができます!基本的に、私はからのタブレイアウトのGoogleサンプルを取得しました ここ

その方法は、各タブ内にテキストが付いたタブを非常に簡単に作成できることがわかりましたが、タブが選択されたときに、以下にリストされているテキストを分割行で区切るようにしようとしています。線が各段落間で分割されているように、しかし私はこれを行うのに苦労しています。これは私がこれまでに持っているものです: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>

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);
    }
}

main.xmlでは、最初の行の「これは1番目のタブの最初の行です」を取得できますが、「これは1番目のタブの2行目です」は最初の行と他のすべてのタブに表示されます。どんな助けにも前もって感謝します。うまくいけば、私の知識を得て、将来他の人を助けることができます。

役に立ちましたか?

解決

単にセパレーター(領域を2つのセクションに分割する線)が必要な場合は、レイアウトXMLファイルで次のコードを使用できます。

<View   android:id="@+id/firstDivider"
        android:layout_height="2dp"
        android:layout_width="fill_parent"
        android:background="#000080" />

上記のコードは、厚さ2dpのネイビーブルーの仕切りを生成します。増加します layout_height 仕切りの厚さが増加します。

任意のクエリに戻します。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top