- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 ListView 添加到 Fragment 上,而不仅仅是 ListFragment。我想要顶部的选项卡而不是 Fragment 中的 ListView。我的代码编译正常,但在启动时崩溃。
这是我正在尝试添加 ListView 的 fragment 。
public static class MainFragment extends Fragment {
public static final String ARG_SECTION_NUMBER = "section_number";
public MainFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Create a new TextView and set its text to the fragment's section
// number argument value.
View V = inflater.inflate(R.layout.main, container, false);
ListView LV = (ListView) this.getActivity().findViewById(R.id.mainList);
String List[] = new String[2];
List[0] = "tst1";
List[1] ="tst2";
ArrayAdapter<String> aa = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_2, List);
LV.setAdapter(aa);
return V;
}
}
我的日志猫说它在 LV.setAdapter(aa) 上崩溃了;
这里是调用 fragment 的完整代码
公共(public)类 MainCalActivity 扩展 FragmentActivity 实现 ActionBar.TabListener {
SectionsPagerAdapter mSectionsPagerAdapter;
/**
* The {@link ViewPager} that will host the section contents.
*/
ViewPager mViewPager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main_cal);
// Set up the action bar.
final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
// Create the adapter that will return a fragment for each of the three
// primary sections of the app.
mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
// Set up the ViewPager with the sections adapter.
mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
// When swiping between different sections, select the corresponding
// tab. We can also use ActionBar.Tab#select() to do this if we have
// a reference to the Tab.
mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
// Create a tab with text corresponding to the page title defined by
// the adapter. Also specify this Activity object, which implements
// the TabListener interface, as the callback (listener) for when
// this tab is selected.
actionBar.addTab(
actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this));
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main_cal, menu);
return true;
}
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
mViewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
@Override
public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
}
/**
* A {@link FragmentPagerAdapter} that returns a fragment corresponding to
* one of the sections/tabs/pages.
*/
public class SectionsPagerAdapter extends FragmentPagerAdapter {
public SectionsPagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public Fragment getItem(int position) {
// getItem is called to instantiate the fragment for the given page.
// Return a DummySectionFragment (defined as a static inner class
// below) with the page number as its lone argument.
Fragment fragment;
Bundle args = new Bundle();
if(position == 0)
{
fragment = new MainFragment();
args.putInt(MainFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
return fragment;
} else
{
fragment = new CalFragment();
args.putInt(MainFragment.ARG_SECTION_NUMBER, position + 1);
fragment.setArguments(args);
return fragment;
}
}
@Override
public int getCount() {
// Show 2 total pages.
return 2;
}
@Override
public CharSequence getPageTitle(int position) {
switch (position) {
case 0:
return getString(R.string.main);
case 1:
return getString(R.string.cal);
}
return null;
}
}
/**
* The Main fragment argument representing the main menu
*/
public static class MainFragment extends Fragment {
public static final String ARG_SECTION_NUMBER = "section_number";
public MainFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Create a new TextView and set its text to the fragment's section
// number argument value.
View V = inflater.inflate(R.layout.main, container, false);
ListView LV = (ListView) this.getActivity().findViewById(R.id.mainList);
String List[] = new String[2];
List[0] = "tst1";
List[1] ="tst2";
ArrayAdapter<String> aa = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_2, List);
LV.setAdapter(aa);
return V;
}
}
/**
* The Calendar fragment argument representing the Calendar
*/
public static class CalFragment extends Fragment {
/**
* The Calendar fragment argument representing the Calendar
*/
public static final String ARG_SECTION_NUMBER = "section_number";
public CalFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View V = inflater.inflate(R.layout.cal, container, false);
return V;
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
vandroid:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/addS"
android:textSize="30sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="246dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/stuff" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:text="@string/add" />
<ListView
android:id="@+id/mainList"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
和我的日志猫
03-21 13:15:13.845: E/ArrayAdapter(837): You must supply a resource ID for a TextView
03-21 13:15:14.015: E/AndroidRuntime(837): FATAL EXCEPTION: main
03-21 13:15:14.015: E/AndroidRuntime(837): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.ListView.onMeasure(ListView.java:1158)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1381)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-21 13:15:14.015: E/AndroidRuntime(837): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.View.measure(View.java:15513)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.Choreographer.doFrame(Choreographer.java:532)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.os.Handler.handleCallback(Handler.java:725)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.os.Handler.dispatchMessage(Handler.java:92)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.os.Looper.loop(Looper.java:137)
03-21 13:15:14.015: E/AndroidRuntime(837): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-21 13:15:14.015: E/AndroidRuntime(837): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 13:15:14.015: E/AndroidRuntime(837): at java.lang.reflect.Method.invoke(Method.java:511)
03-21 13:15:14.015: E/AndroidRuntime(837): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-21 13:15:14.015: E/AndroidRuntime(837): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-21 13:15:14.015: E/AndroidRuntime(837): at dalvik.system.NativeStart.main(Native Method)
03-21 13:15:14.015: E/AndroidRuntime(837): Caused by: java.lang.ClassCastException: android.widget.TwoLineListItem cannot be cast to android.widget.TextView
03-21 13:15:14.015: E/AndroidRuntime(837): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:379)
03-21 13:15:14.015: E/AndroidRuntime(837): ... 43 more
03-21 13:15:39.406: E/Trace(915): error opening trace file: No such file or directory (2)
03-21 13:15:40.465: E/ArrayAdapter(915): You must supply a resource ID for a TextView
03-21 13:15:40.495: E/AndroidRuntime(915): FATAL EXCEPTION: main
03-21 13:15:40.495: E/AndroidRuntime(915): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.ListView.onMeasure(ListView.java:1158)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1381)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-21 13:15:40.495: E/AndroidRuntime(915): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.View.measure(View.java:15513)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.Choreographer.doFrame(Choreographer.java:532)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.os.Handler.handleCallback(Handler.java:725)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.os.Handler.dispatchMessage(Handler.java:92)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.os.Looper.loop(Looper.java:137)
03-21 13:15:40.495: E/AndroidRuntime(915): at android.app.ActivityThread.main(ActivityThread.java:5039)
03-21 13:15:40.495: E/AndroidRuntime(915): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 13:15:40.495: E/AndroidRuntime(915): at java.lang.reflect.Method.invoke(Method.java:511)
03-21 13:15:40.495: E/AndroidRuntime(915): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
03-21 13:15:40.495: E/AndroidRuntime(915): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
03-21 13:15:40.495: E/AndroidRuntime(915): at dalvik.system.NativeStart.main(Native Method)
03-21 13:15:40.495: E/AndroidRuntime(915): Caused by: java.lang.ClassCastException: android.widget.TwoLineListItem cannot be cast to android.widget.TextView
03-21 13:15:40.495: E/AndroidRuntime(915): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:379)
03-21 13:15:40.495: E/AndroidRuntime(915): ... 43 more
最佳答案
堆栈跟踪告诉您代码有什么问题:java.lang.IllegalStateException: ArrayAdapter 要求资源 ID 为 TextView
你正在使用
new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_2, List);
这是构造函数:
public ArrayAdapter (Context context, int textViewResourceId, T[] objects)
文档对 textViewResourceId 说:包含在实例化 View 时使用的 TextView 的布局文件的资源 ID(请参阅 http://developer.android.com/reference/android/widget/ArrayAdapter.html#ArrayAdapter(android.content.Context, int))
因为您正在使用的布局是一个更复杂的布局 (TwoLineListItem),您必须告诉适配器要使用哪个 TextView:
new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_2, android.R.id.text1, List);
或者您可以只使用简单布局 android.R.layout.simple_list_item_1。
new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, List);
无论如何,使用两行布局在您的情况下没有任何意义,因为您似乎每行只有一个文本。
关于Android:Fragment 布局中的 ListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15547997/
我有一个像这样的 fragment 栈 F1 -> F2 -> F3 -> F4 -> F5 现在我需要删除 F2、F3、F4 fragment 。 我需要如果我从 F5 fragment 按下后退按
我需要帮助来理解以下场景的工作原理以及如何实现结果。 我有一个名为 ShoppingCart 的类。它有一个名为 addItemsToShoppingCartFromPreviousOrder 的方法
我有一个包含 ViewPager 的 fragment 。这个 ViewPager 显然是由其他 Fragments 填充的。 我的问题是,ViewPager 中的 Fragment 是否有任何方法(
所以我正在实现一个 FragmentActivity 并尝试添加一个 fragment ,但是我遇到了多个问题。我以前做过这个,实际上我使用的代码与上一个项目(它工作的地方)相同,但由于某种原因它在这
Closed. This question needs details or clarity。它当前不接受答案。
我想将 Android X fragment (androidx.fragment.app.Fragment) 转换为 Android native fragment (android.app.Fra
假设我有一个包含 10 列文本类型 (20) 的 SQLite 表。 ListFragment 将从数据库中提取 4 列并使用 SimpleCursorAdapter 显示在列表中。 选择后,List
我有一个对话框 fragment ,我为延迟初始化创建了一个类。当我显示对话框时,它显示正常。但是,当我关闭对话框时,它崩溃的原因是: fragment 与 fragment 管理器无关。 我也尝试过
我想在 View 分页器更改为 fragment 时刷新该 fragment 。 package com.mcivisoft.rcbeam; import android.os.Bundle; imp
我有一个名为的 Activity MainActivity 我在容器 R.id.mainContainer 中添加了 fragment “BenefitFragment”。 在 BenefitFrag
所以我有这个 ClientListView,效果很好,可以显示客户,我可以单击一个客户并在右侧获取他们的详细信息(在我的第二个 fragment 中)。由此处的布局定义: 这很好用,但后来我
我试过这段代码,但点击第一个 fragment 中的按钮并没有改变第二个 fragment 中的字符串值。 这是第一个 fragment 的 kotlin 文件。它有两个按钮,点击它们可以更改字符串值
我有以下情况:我打开 fragment A 和目标,通过按钮的单击事件转到 fragment B。当我在 fragment B 中并点击后退按钮(为了返回 fragment A) 我想将一些参数传递给
我制作了一个 NavigationDrawer fragment ,其中包含 Home、Settings、Feedback 等项目。 home 项在点击 home 时应该打开,home 是在应用程序启
我正在一个接一个地替换 2 个 fragment ,两个 fragment 都有不同的选项菜单。当我替换第二个 fragment 时,它也显示第一个 fragment 的菜单。 setHasOptio
我有问题: android.app.Fragment$InstantiationException: Unable to instantiate fragment ${packageName}.${a
我正在研究 fragment 转换。当我用第二个 fragment 替换第一个 fragment 时,它出现在第一个 fragment 的下方。我希望它移动到第一个 fragment 之上。我该怎么做
我在抽屉导航里总共有 12 个 fragment 。每个 fragment 都有 volley 方法。每个 fragment 都显示自己的 Volley 响应,除了 position = 1 和 po
我在我的 Activity 中使用了两个 fragment 。最初我将向 Activity 添加一个 fragment 。然后在第一个 fragment 中使用监听器我想用第二个 fragment 替
我正在实现一个“fragments-101”程序,当相应的按钮被点击时我会替换一个 fragment 。然而,下面的事情发生了: 为什么会这样?为什么初始 fragment 没有被完全替换?MainA
我是一名优秀的程序员,十分优秀!