I have an app that switches between two different activities (Main Activity with a simple text and Second Activity with two TextViews) in Android with different layouts every 10 seconds.
I want in Second Activity at the first time display only the first textView A, then return to the MainActivity and again lead to the Second Activity but display only the second textView B.
activity_second.xml:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="255dp"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/holo_purple"
android:orientation="horizontal">
<TextView
android:id="@+id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="A"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textSize="65sp" />
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@android:color/holo_orange_light"
android:orientation="horizontal">
<TextView
android:id="@+id/textViewB"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="B"
android:textAppearance="@style/TextAppearance.AppCompat.Large"
android:textSize="65sp" />
</LinearLayout>
</LinearLayout>
And java code that switches between two Activities provided bellow.
Second_activity.java:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.second_activity);
timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
Intent intent = new Intent(SecondActivity.this, MainActivity.class);
startActivity(intent);
finish();
}
}, 10000);
........
}
My problem is how to change the visibility of the two textViews for every time that switches between two activities.