Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 有没有办法重新刷新或重新创建自定义视图?_Android_Android Custom View - Fatal编程技术网

Android 有没有办法重新刷新或重新创建自定义视图?

Android 有没有办法重新刷新或重新创建自定义视图?,android,android-custom-view,Android,Android Custom View,我创建了一个自定义视图类,这个类包含三个文本视图。我只是在片段布局的基础上使用这个自定义视图。我的布局如下 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <com.abc.views.HeaderView

我创建了一个自定义视图类,这个类包含三个文本视图。我只是在片段布局的基础上使用这个自定义视图。我的布局如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <com.abc.views.HeaderView
        android:id="@+id/headerView"
        android:visibility="visible"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    </com.rfs.app.views.HeaderView>

    <ScrollView
        android:id="@+id/widget54"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/footerView"
        android:layout_below="@+id/headerView" >

       --------------------------------------
       --------------------------------------

    </ScrollView>
</RelativeLayout>
问题是,当我点击片段中的按钮时,HeaderView孩子的更新更改文本/颜色。这些变化并没有立即反映出来

所有孩子的都是HeaderView类中的文本视图


有没有办法重新刷新或重新创建此自定义视图?

显然,您的自定义视图不会正确地使自身失效。如果在后台线程中工作,请确保在您希望自定义视图调用onDraw时调用invalidate或postInvalidate。您可以共享自定义视图代码,以便我们在此指出问题。

使视图无效!请添加java代码