通过 按钮 bundle 传过来 变换Q币图片
16lz
2021-12-04
第一种
直接用 java 配合 xml (第一最方面的了。。第二种我是想多了 )
<ImageView android:id="@+id/qqicon" android:layout_marginTop="15dip" android:layout_gravity="center" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <!-- QQ图标 -->
java
img = (ImageView)findViewById(R.id.qqicon); img.setImageResource(R.drawable.qq_c); //用if语句 大于等于 什么数值 控制 他的图片变化。。。。。。。qb = b.getInt("qb",qb);//显示相应的Q币图片switch (qb) {case 1:img.setImageResource(R.drawable.qb1); //1Q币break;case 5:img.setImageResource(R.drawable.qb5); //5Q币break;case 10:img.setImageResource(R.drawable.qb10); //10Q币break;case 20:img.setImageResource(R.drawable.qb20); //20Q币break; }
第二种
基本用java代码写 不过 要先在 xml
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id = "@+id/Linear_QQicon" >
Linear_QQ = (LinearLayout)findViewById(R.id.Linear_QQicon);LinearLayout llt = new LinearLayout(ActivityExchange_QQ_commit.this);LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);params.gravity = Gravity.CENTER ; ImageView img = new ImageView(ActivityExchange_QQ_commit.this); img = (ImageView)findViewById(R.id.qqicon); img.setImageResource(R.drawable.qq_c); //用if语句 大于等于 什么数值 控制 他的图片变化 // Linear_QQ.addView(img,params) ; qb = b.getInt("qb",qb); //显示相应的Q币图片 switch (qb) { case 1: img.setImageResource(R.drawable.qb1); //1Q币 break; case 5: img.setImageResource(R.drawable.qb5); //5Q币 break; case 10: img.setImageResource(R.drawable.qb10); //10Q币 break; case 20: img.setImageResource(R.drawable.qb20); //20Q币 break; }
更多相关文章
- Android(安卓)人脸识别
- android官网demo之异步加载图片
- [Android(安卓)UI] ActionBar 自定义属性
- Android(安卓)调用手机系统照相机拍照
- 关于Android(安卓)获得图片的总结
- Android(安卓)ImageView、TextureView、自定义View显示图片
- android 背景圆角以及图片圆角处理
- Android储存BMP格式图片
- drawable中的layer-list使用