I'm trying to create a homescreen Android widget and have it alternate between two different textviews I would send to it. Is this possible?
views:
22answers:
2
A:
Why not maintain the same textview and just change the text shown?
If you really must use 2 text views you can use the setViewVisibility method in the RemoteViews object to alternate between GONE (which means not shown to user, takes up no screen space) and VISIBLE (shown to user, takes up screen space).
Al Sutton
2010-07-02 05:47:29
A:
You could use a ViewFlipper to switch between multiple text views if that's what you meant.
<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));
You could use a button event to switch between the text Views.
Button learn_more = (Button) findViewById(R.id.button);
learn_more.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
mFlipper.showNext();
}
});
Hope it helps.
primalpop
2010-07-02 05:57:01