:235.916KB : :1 :2021-11-29 20:23:30
android imageview 图片背景切换效果实例对于感兴趣的可以参考。
public class ImageViewActivity extends Activity {
/* 声明 Button、ImageView对象 */
private ImageView mImageView01;
private ImageView mImageView02;
private Button mButton01;
private Button mButton02;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
/* 取得 Button、ImageView对象 */
mImageView01 = (ImageView) findViewById(R.id.myImageView1);
mImageView02 = (ImageView) findViewById(R.id.myImageView2);
mButton01 = (Button) findViewById(R.id.myButton1);
mButton02 = (Button) findViewById(R.id.myButton2);
/* 设置ImageView背景图 */
mImageView01.setImageDrawable(getResources().getDrawable(
R.drawable.right));
mImageView02
.setImageDrawable(getResources().getDrawable(R.drawable.oa));
/* 用OnClickListener事件来启动 */
mButton01.setOnClickListener(new Button.OnClickListener() {
public void onClick(View v) {
/* 当启动后,ImageView立刻换背景图 */
mImageView01.setImageDrawable(getResources().getDrawable(
R.drawable.right));
}
});
mButton02.setOnClickListener(new Button.OnClickListener() {
@Override
public void onClick(View v) {
mImageView01.setImageDrawable(getResources().getDrawable(
R.drawable.left));
}
});
}
}
10-12Android游戏案例开发大全
10-12mtk7668蓝牙驱动(Android)
10-04高通Android平台开发
08-21动画框画工具条,支持透明背景,图片背景