如何在选项卡式活动中重新创建视图

时间:2017-06-19 05:22:57

标签: android android-fragments android-tabbed-activity

我正在从空白活动更改为选项卡式活动。我想在某些点重新创建视图。我试过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个标签都有相同的结构。 我希望这样做。

0 个答案:

没有答案