Android - 使用ViewFlipper更改显示的子项之前的setText

时间:2013-06-15 10:35:54

标签: android textview viewflipper

我正在尝试使用TextView.setText更改文字,但在我用ViewFlipper更改显示的setDisplayedChild子项后,它会更新。我也尝试调用invalidate但它不起作用,文本在显示视图后发生变化(无需立即调用invalidate)。

代码:

TextView text = (TextView) findViewById(R.id.summary);
text.setText( /* text here */ );
flipper.setDisplayedChild(NUMBER);

我相信这些都是在UI线程上调用的。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我已经解决了这个问题。将textview放在另一个容器中。比如

在Oncreate Mehtod

newsFeedTextView.setSelected(true); 

它会挑战work.enjoy

<LinearLayout
    android:id="@+id/newsLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true" >

    <TextView
        android:id="@+id/newsFeedTextView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/splash_bg"
        android:ellipsize="marquee"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:freezesText="true"
        android:marqueeRepeatLimit="marquee_forever"
        android:padding="10dp"
        android:scrollHorizontally="true"
        android:singleLine="true"
        android:text="Manchester United boss David Moyes is from the Champions League."
        android:textColor="@android:color/white"
        android:textStyle="bold" />
      </LinearLayout>