
Drawable background = buttongetBackground();
ColorDrawable colorDrawable = (ColorDrawable) background;
int color = colorDrawablegetColor();
button1setBackgroundColor(color);
其实我也不知道咋获取,看到问题之后自行调试了一下,顺着代码走走或许你就会一不小心发现了。
设置一个变量int whichEditText=0;在RadioGroup的监听事件中设置whichEditText的值
// RadioGroup的监听事件
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (checkedId == rb_1getId()) {
whichEditText= 1;
} else if (checkedId == rb_2getId()) {
whichEditText= 2;
} else if (checkedId == rb_3getId()) {
whichEditText = 3;
} else if (checkedId == rb_4getId()) {
whichEditText= 4;
}else if (checkedId == rb_5getId()) {
whichEditText= 5;
}
}
然后再在确认按钮的监听事件中,用switch语句根据whichEditText的值来选择获取哪个EditText的值
用Button完不成你的需求,我认为5个Button的设计可以改为ListView或者GridView来做,这样好布局,按下其中一个Item就刷新一遍。
这样问题二就不存在了,你不需要考虑了,按下其中一个Item之后,TextView和ListView就刷新了。
你把xml中的Button删掉,代码中
btn=new Button(this);在这一行后,加一句这个:
btnsetText(Rstringbtn_text);//给button赋一个初始的值
以上就是关于如何能获取android按钮背景的颜色全部的内容,包括:如何能获取android按钮背景的颜色、android单击button后,获取某个控件的值,怎么获取、android 一个activity下面 如何动态获取按钮的事件等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)