2010-07-01 30 views

回答

0

爲什麼不保持相同的文本視圖,只是改變顯示的文本?

如果您確實必須使用2個文本視圖,則可以使用RemoteViews對象中的setViewVisibility方法在GONE(表示不顯示給用戶,不佔用屏幕空間)和VISIBLE(顯示給用戶,佔用屏幕空間)。

0

如果這就是你的意思,你可以使用ViewFlipper在多個文本視圖之間切換。

<ViewFlipper android:id="@+id/flipper" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:outAnimation="@anim/push_left_out" 
       android:inAnimation="@anim/push_left_in"> 

       <TextView android:layout_height="fill_parent" 
        android:layout_width="fill_parent" android:padding="16dip" 
        android:id="@+id/txt1" android:textSize="8pt" 
        android:textColor="#ffffffff" 
        android:text="@string/text1"/> 
       <TextView android:layout_height="fill_parent" 
        android:layout_width="fill_parent" android:padding="16dip" 
        android:id="@+id/txt1" android:textSize="8pt" 
        android:textColor="#ffffffff" 
        android:text="@string/text2"/> 
</ViewFlipper> 


ViewFlipper mFlipper = ((ViewFlipper) this.findViewById(R.id.flipper)); 

您可以使用按鈕事件在文本Views之間切換。

Button learn_more = (Button) findViewById(R.id.button); 
     learn_more.setOnClickListener(new OnClickListener() { 
      public void onClick(View v) { 
       mFlipper.showNext(); 

      } 
     }); 

希望它有幫助。

相關問題