我正在从空白活动更改为选项卡式活动。我想在某些点重新创建视图。我已经尝试notifyDataSetChanged
过
getFragmentManager().beginTransaction().replace (R.id.container, PlaceholderFragment.newInstance(1)).commit();
但他们没有工作。如何重新创建选项卡?
另外,一个小问题,在更改活动期间复制/粘贴时,我需要将 onStart 复制到片段的 onStart 并将 onStop 复制到 onDestroyView。正确的?
编辑1:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#e0e0e0"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="lcukerd.com.stocknotifier.MainActivity"
tools:showIn="@layout/activity_main">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="120dp"
android:id="@+id/stock_linear"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/value_linear"
android:layout_width="90dp"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/reqd_value_linear"
android:layout_width="90dp"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
<LinearLayout
android:id="@+id/check_linear"
android:layout_width="80dp"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</LinearLayout>
我正在动态地用 textview 填充它们。我有 3 个选项卡都具有相同的结构。我希望这会做到。