Button点击后,实现Button背景图片的转换。 先绑定控件,然后再button的onclick事件里面写,设置控件背景颜色 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 写个selector图形资源不行吗? 难道是理解错了楼主的意思了,这个没有那么难吧,Button but=new Button(this); but.setText("按钮"); but.setBackgroundColor(Color.GRAY); but.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub v.setBackgroundColor(Color.LTGRAY); } }); <?xml version="1.0" encoding="UTF-8"?>你在drawable文件夹下定义这样的xml问题,然后这个xml文件当做一张图片设置给button就可以了啊<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/dialog_button_focus" /> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/dialog_button_focus" /> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/dialog_button_focus" /> <item android:state_focused="false" android:state_pressed="false" android:drawable="@drawable/dialog_button_unfocus" /></selector> 你在drawable文件夹下定义这样的xml文件,然后这个xml文件当做一张图片设置给button就可以了啊 <?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/title_btn_l_color" /> <item android:drawable="@drawable/chat_title_btn_l" /></selector>要这样的?还是要but_NotPublished.setBackgroundDrawable(label_right_def); but_ThePublished.setBackgroundDrawable(label_left_sel); android中AudioRecord录音,并实时转码为MP3进行保存 如何在android系统里面捕获外接键盘键值 关于android开机优化的问题(java世界起来以后) 高手来看看,给高分 android 程序自带文件问题 Android 文件读写问题 lan8720网卡mac地址如何固定android4.0(linux2.6.34) Android webview怎么播放网页中的视频? 请问关于运行程序,提示activity没有找到的问题 求解android listview的居中(已经附上xml代码) android应用如何快速显示网络图片 朋友们 帮帮 小弟
Button but=new Button(this);
but.setText("按钮");
but.setBackgroundColor(Color.GRAY);
but.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
v.setBackgroundColor(Color.LTGRAY);
}
});
你在drawable文件夹下定义这样的xml问题,然后这个xml文件当做一张图片设置给button就可以了啊
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_pressed="false"
android:drawable="@drawable/dialog_button_focus" /> <item android:state_focused="true" android:state_pressed="true"
android:drawable="@drawable/dialog_button_focus" /> <item android:state_focused="false" android:state_pressed="true"
android:drawable="@drawable/dialog_button_focus" /> <item android:state_focused="false" android:state_pressed="false"
android:drawable="@drawable/dialog_button_unfocus" /></selector>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/title_btn_l_color" />
<item android:drawable="@drawable/chat_title_btn_l" />
</selector>要这样的?
还是要
but_NotPublished.setBackgroundDrawable(label_right_def);
but_ThePublished.setBackgroundDrawable(label_left_sel);