Reputation: 19
how to update textview from another activity help me please i want if condition sucessfull in another classs change textview value this code not work for me please help me
public class NotificationDetail extends Activity {
public static TextView pickpplots, destinatonplots;
pickpplots = (TextView) findViewById(R.id.pickuppointplot);
destinatonplots = (TextView) findViewById(R.id.destinationplot);
pickpplots.setText(pickuplist.get(1));
destinatonplots.setText(destlist.get(1));
now i want in second activity if condition true change textview values
public class LatlongService extends Service {
String Pikup,Dest,Pickupdate,Cust,Mob;
Pikup=listmessang.get(3);
Dest=listmessang.get(4);
if (NotificationDetail.not_detail != null)
{
NotificationDetail.pickpplots.setText("");
NotificationDetail.destinatonplots.setText("");
NotificationDetail.pickpplots.setText(Pikup.toString());
NotificationDetail.destinatonplots.setText(Dest.toString());
Upvotes: 0
Views: 1539
Reputation: 831
I think you are new to android.
See we can use a Util class say
public class AppUtils{
public Static String string1="default text";
}
now set this value from the activity you want. Say inside activity that doesn't has reference of that TextView you want to change
public void onButtonOneClick(){
AppUtils.string1 = "Desired String";
}
and use in the activity which holds the TextView.
textView1.setText(AppUtils.string1);
Upvotes: 0
Reputation: 2531
You can use Shared Preferences for saving data, or create public static String data;
in your activity, then you have access to that field across whole application.
Upvotes: 1