フラグメント内にタブを作成しようとしています。私は "Food_layout.xml"というフラグメントを持っていますフラグメント内にタブを作成する方法の例は?
ここはxmlファイルです。ここで
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:text="Food Layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="149dp"
android:layout_marginStart="149dp"
android:layout_marginTop="199dp"
android:id="@+id/textView3" />
</RelativeLayout>
は、フラグメント
package com.example.crims.plfitness;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class FoodFragment extends Fragment{
View myView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
myView = inflater.inflate(R.layout.food_layout, container, false);
return myView;
}
}
私はTabHostを追加しようとしたが、私はプログラムを実行すると、それが表示されていなかったのJavaクラスです。子フラグメントマネージャーを使う必要があると言われました。私はそれを調べましたが、実際にそれを実装する方法については何も見つかりませんでした。私はアンドロイド開発に新しいです。
を追加することができます! –
http://stackoverflow.com/questions/20469877/adding-tab-inside-fragment-in-android http://stackoverflow.com/questions/25479980/creating-tabs-inside-fragment http://stackoverflow.com/questions/23988654/how-to-add-tab-inside-fragment-in-android http://stackoverflow.com/questions/34778063/viewpager-tabs-fragment-normal-fragments http://stackoverflow.com/questions/34428511/tablayout-with-viewpager-not-working-inside-fragment-android http://stackoverflow.com/questions/35058819/android-tablayout-inside-fragment –
これは、アクティビティに追加したのと同じ方法で行います。どこでも 'getSupportFragmentManager()'と書かれたどこでも 'getChildFragmentManager()'を書く –