2015-09-04 42 views
-2

我已经创建了自定义视图类,该类包含三个TextViews。我只是在我的Fragment布局中使用这个自定义视图。我的布局如下有什么方法可以重新创建或重新创建自定义视图?

<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类中的textviews。

有什么方法可以重新创建或重新创建这个自定义视图吗?

+2

使视图无效! – Raghunandan

+1

请添加java代码 – FadedCoder

回答

0

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