I have the activity in which I bundle data to another activity. With that data I also bundle a custom color that I would like to have bottom line of EditText shown in activity 2.
Activity 1:
Bundle bundle = new Bundle();
bundle.putExtra("Color", color);
Activity 2:
int value = getIntent().getExtras().getInt(Color)
Now, can I change the color of EditText programmatically when I get the bundle from activity 1? If you can help me with that I would be really grateful.
Might be something like,
Activity 2//
int value = getIntent().getExtras().getInt(Color);
// Here I assume you have defined edittext form layout file so it is not null
editText.getBackground().setColorFilter(value, PorterDuff.Mode.SRC_ATOP);
Try this and let me know, It works or not.
Activity 1
Intent intent = new Intent(Activity1.this, Activity2.class);
Bundle bundle = new Bundle();
bundle.putInt("Color", color); //Your id
intent.putExtras(bundle); //Put your id to your next Intent
startActivity(intent);
finish();
Activity 2
Bundle b = getIntent().getExtras();
int value = b.getInt("Color");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.