I am developing a project which has multiple activities and each activity sets values in Textview
. Also I'm using same xml file containing multiple Textviews
for all activities. I created multiple text view in one xml file. I don't know how to kept value of one activity in text view as new activity started it reload xml again so old value gone.
My activity runs sequentially and I want that if activity one set TCP Download(id) and other activity set TCP Upload(id), while TCP Upload setting value TCP Download value should intake not disappear
I want display value not vanished as new activity setContentView(R.layout.main) called it reload xml again and I want already set TextView value not disappear as intent pass to new activity.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/black"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="@+id/tcpdownload1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="TCP Download: "
android:textColor="#FFFFFF"
android:textSize="16dip"
android:layout_gravity="left"
/>
<TextView
android:id="@+id/tcpdownload"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:textSize="16dip"
android:layout_gravity="right" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tcpupload1"
android:text="TCP Upload: "
android:textColor="#FFFFFF" android:textSize="16dip"/>
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/tcpupload"
android:textColor="#FFFFFF" android:textSize="16dip"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tcprtt1"
android:text="TCP RTT"
android:layout_marginTop="10dip" android:textColor="#FFFFFF"
android:textSize="16dip"/>
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/tcprtt"
android:layout_marginTop="10dip"
android:textColor="#FFFFFF"
android:textSize="16dip"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/packetloss1"
android:text="Packet Loss"
android:layout_marginTop="10dip"
android:textColor="#FFFFFF" android:textSize="16dip"/>
<TextView
android:layout_width="120dp"
android:layout_height="wrap_content"
android:id="@+id/packetloss"
android:layout_marginTop="10dip"
android:textColor="#FFFFFF" android:textSize="16dip"/>
</LinearLayout>
</LinearLayout>
activity A set value of id1 and now activity A --> activity B, in activity B i want to set value of id2 but i also want id1 value in display
You want to keep the
TextView
values while switching activities right?? You can save values in a sharedPref or simply hold values in a different class/model also you can pass values from one activity to other usingintent
for eg: