2017-01-02 8 views
2

私は、下の図のようなスワイプ可能なタブレイアウトを作成できるかどうかを知りたいのですが、sqliteデータベースから日付を取得し、tablayout.canで表示しています。私はタブレイアウトに日付を表​​示することができる例です。私は静的な名前のtablayoutを与えましたが、私は動的にそれを作成したいと思います。spendeeアプリのようにスワイプ可能なtablayoutを作成する方法

enter image description here

+0

あなたは何を試しましたか?そのコードを投稿してください。 – Ironman

+0

@アイロンマン私はarraylistで与えられた静的データを持つビューページを持つtablayoutを作成しました –

+0

[こちら]をチェックしてください(http://www.android4devs.com/2015/01/how-to-make-material-design -sliding-tabs.html)チュートリアル –

答えて

1

使用TabLayoutとViewPagerサンプルコード

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <android.support.design.widget.TabLayout 
     android:id="@+id/mydriverveh_tabLayout" 
     android:layout_width="match_parent" 
     android:layout_height="50dp" 
     app:tabGravity="fill" 
     /> 

    <android.support.v4.view.ViewPager 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"/> 

</LinearLayout> 

その後、FragmentPagerAdapterで拡張Viewpagerアダプタを作成し、scrollableタブ

と呼ばれる

0

ザッツをアダプタために断片を追加作成しますの新しい活動ViewPagerタブ とTabLayoutで、そのモードをScrollableに設定しました。

<android.support.design.widget.TabLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/tabs" 
app:tabMode="scrollable" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" /> 

このページでは、このページを参照して、視聴者のタブアクティビティを作成しています。 TabLayout with viewPager

関連する問題