[android]代码库
mImageButton1.setOnFocusChangeListener(new OnFocusChangeListener() {
public void onFocusChange(View arg0, boolean isFocused) {
// TODO Auto-generated method stub
/* 若ImageButton状态为onFocus改变ImageButton的图片 * 并改变textView的文字 */
if (isFocused == true) {
mTextView1.setText("图片按钮状态为:Got Focus");
mImageButton1.setImageResource(R.drawable.iconfull);
}
/* 若ImageButton状态为offFocus改变ImageButton的图片 *并改变textView的文字 */
else {
mTextView1.setText("图片按钮状态为:Lost Focus");
mImageButton1.setImageResource(R.drawable.iconempty);
}
}
});