[英]how to change EditText bottom line programmatically
我有将数据捆绑到另一个活动的活动。 有了这些数据,我还捆绑了一个自定义颜色,我希望在活动2中显示EditText的底线。
活动1:
Bundle bundle = new Bundle();
bundle.putExtra("Color", color);
活动2:
int value = getIntent().getExtras().getInt(Color)
现在,当我从活动1获取捆绑包时,我可以以编程方式更改EditText的颜色吗? 如果你可以帮助我,我会非常感激。
可能是这样的,
活动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);
试试这个让我知道,它的工作与否。
活动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();
活动2
Bundle b = getIntent().getExtras();
int value = b.getInt("Color");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.