现在的情况为:我想通过执行一个方法后将某个ImageView的背景图片更换,附上代码:
public void changeTVChannel(String channelCode) {
if (null != socketClient) {
//切台成功
// socketClient.sendDataToServerSocket(Const.DAOSHI_EPG_CHANGECHANNEL + ":" + channelCode);
Log.e("切台成功!", "切台成功!");
img_demand.setBackgroundResource(R.drawable.icon_tv_on);
icon_link.setVisibility(View.VISIBLE);
line.setVisibility(View.VISIBLE);
}
}
程序跑完后,这里面的Log.e也打印了,下面2个控件也都显示了。就是img_demand的背景图片未更换。下面附上img_demand在xml中的布局:
<RelativeLayout>
<TextView
android:id="@+id/cctv_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cctv_title"
android:layout_marginLeft="100dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/img_demand"
android:ellipsize="end"
android:maxLines="2"
android:text="啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"
android:textColor="#696969"
android:textSize="18dp" /> <ImageView
android:id="@+id/img_demand"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_marginTop="40dp"
android:background="@drawable/icon_tv" />
</RelativeLayout>
请各位不吝指教以下小弟,不甚感激
public void changeTVChannel(String channelCode) {
if (null != socketClient) {
//切台成功
// socketClient.sendDataToServerSocket(Const.DAOSHI_EPG_CHANGECHANNEL + ":" + channelCode);
Log.e("切台成功!", "切台成功!");
img_demand.setBackgroundResource(R.drawable.icon_tv_on);
icon_link.setVisibility(View.VISIBLE);
line.setVisibility(View.VISIBLE);
}
}
程序跑完后,这里面的Log.e也打印了,下面2个控件也都显示了。就是img_demand的背景图片未更换。下面附上img_demand在xml中的布局:
<RelativeLayout>
<TextView
android:id="@+id/cctv_description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/cctv_title"
android:layout_marginLeft="100dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/img_demand"
android:ellipsize="end"
android:maxLines="2"
android:text="啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊"
android:textColor="#696969"
android:textSize="18dp" /> <ImageView
android:id="@+id/img_demand"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_marginTop="40dp"
android:background="@drawable/icon_tv" />
</RelativeLayout>
请各位不吝指教以下小弟,不甚感激
解决方案 »
- 用移动基站定位,已经获取CID和LACID怎样得到具体的地址
- Android src文件夹中的java类用怎样的文件夹去组织比较好?你们是用怎样的设计模式去分层到底?
- 编译ffmpeg时如何进行neon优化?
- 关于activity启动顺序和参数设置的探讨?
- 关于Broadcast接收的问题
- 第一次学ANDROID,做个界面不知道为什么下面那排控件显示不了
- 怎样载入全局图片?
- 重力传感器和加速度传感器有什么区别?
- 基于open street map的地图引擎,支持离线地图。
- 谁能提供cocos2d for android 的API
- 接收短信遇到中文乱码的问题?
- surfaceView 播放视频,图像被拉伸问题如何解决?
img_demand.setBackgroundDrawable(icon_tv_on);
子线程更新UI会出现各种问题嘞~