Android 嵌套片段(选项卡中的多窗格)
我无法在片段中使用片段。第一个片段是一个选项卡视图,在一个选项卡中我希望有一个如下的多窗格布局: 错误是: android.view.InflateException:二进制XML文件行#8:错误 膨胀类片段 选项卡片段(设置片段框): xml(fragment\u settings\u box.xml):Android 嵌套片段(选项卡中的多窗格),android,android-fragments,nested,Android,Android Fragments,Nested,我无法在片段中使用片段。第一个片段是一个选项卡视图,在一个选项卡中我希望有一个如下的多窗格布局: 错误是: android.view.InflateException:二进制XML文件行#8:错误 膨胀类片段 选项卡片段(设置片段框): xml(fragment\u settings\u box.xml): 通常在活动中使用片段,而不是在其他片段中。你确定你真的想要其他片段中的片段吗 您所指的图片显示了此场景(活动包含片段A或片段B)。您应该阅读http://developer.android
通常在活动中使用片段,而不是在其他片段中。你确定你真的想要其他片段中的片段吗
您所指的图片显示了此场景(活动包含片段A或片段B)。您应该阅读
http://developer.android.com/training/multiscreen/screensizes.html
以处理不同的屏幕大小。有一个布局包含两个片段的示例。通过阅读此http://developer.android.com/training/multiscreen/adaptui.html
我有一个像本教程中那样的选项卡布局:现在希望在一个选项卡中有一个像本教程中那样的片段视图:我的选项卡示例和多平面视图都适用于他们自己。但是现在我有一个问题要把它们结合起来。
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class SettingsFragmentBox extends Fragment implements SettingsFragmentBoxList.OnItemSelectedListener{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_settings_box, container, false);
return rootView;
}
public void onBoxSelect(int id) {
SettingsFragmentBoxDetail fragment = (SettingsFragmentBoxDetail) getFragmentManager().findFragmentById(R.id.box_detail);
if (fragment != null && fragment.isInLayout()) {
fragment.setText(id);
} else {
Intent intent = new Intent(getActivity(),SettingsActivityBoxDetail.class);
intent.putExtra(SettingsActivityBoxDetail.EXTRA_ID, id);
startActivity(intent);
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >
<fragment
android:id="@+id/box_list"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
class="de.resper.e2cast.SettingsFragmentBoxList"
tools:layout="@layout/fragment_settings_box_list">
</fragment>
<fragment
android:id="@+id/box_detail"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2"
class="de.resper.e2cast.SettingsFragmentBoxDetail"
tools:layout="@layout/fragment_settings_box_detail">
</fragment>
</LinearLayout>