<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#FFFFFF" /> <corners android:radius="4dip"/> <stroke android:width="1dip" android:color="#BDC7D8" /> </shape>
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#FFFFFF" /> <corners android:radius="4dip"/> <stroke android:width="1dip" android:color="#728ea3" /> </shape>
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_window_focused="false" android:drawable="@drawable/shape_edit_normal"/> <item android:state_focused="true" android:drawable="@drawable/shape_edit_focus"/> </selector>
...... <EditText android:background="drawable/selector_edit_frame" android:layout_width="match_parent" android:layout_weight="wrap_content"/> ......
protected void onCreate(Bundle savedInstanceState) { Button loginBtn = (Button)findViewById(R.id.login); EditText secCode = (EditText) findViewById(R.id.login_security_code); secCode.addTextChangedListener(new TextWatcher() { /** *文本编辑框内容未改变前回调该方法 */ public void beforeTextChanged(CharSequence s, int start, int count, int after) { loginBtn.setEnabled(false); // loginBtn.setBackgroundColor(Color.parseColor("#DEB887")); } /** *文本编辑框内容改变时回调该方法 */ public void onTextChanged(CharSequence s, int start, int before, int count) { loginBtn.setEnabled(false); loginBtn.setBackgroundColor(Color.parseColor("#DEB887")); } /** *文本编辑框内容改变后回调该方法 */ public void afterTextChanged(Editable s) { if (secCode.getText().toString().equalsIgnoreCase(verityCode)) { loginBtn.setEnabled(true); loginBtn.setBackgroundResource(R.drawable.selector_btn_background); } } }); }
原文地址:http://blog.csdn.net/u012637501/article/details/46529865