【发布时间】:2014-09-13 10:58:25
【问题描述】:
可能我做得不对。我试图在单击按钮后立即更改图像。但无论我采用哪种方式,至少需要 1/1.5 秒才能获得更改后的图像。我认为这可能是由于图像大小而发生的。但是缩小尺寸后,问题仍然存在。我试着按照this link中所说的去做
但没有运气。图像仍然会延迟变化。
有人可以帮我用正确的方法吗?
这是我用来更改图像的代码。
button.setOnClickListener(new OnClickListener(){
public void onClick(View arg0){
if(isOn){
portrait.setImageResource(R.drawable.torch1);
}/
单击按钮后,我想立即更改资源图像。
这是我用来显示图像的 xml 块。
<ImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignTop="@id/inside_imageview"
android:layout_alignBottom="@id/inside_imageview"
android:layout_alignLeft="@id/inside_imageview"
android:layout_alignRight="@id/inside_imageview"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:soundEffectsEnabled="true"
android:contentDescription="@string/desc"
android:src="@drawable/on"
android:scaleType="fitXY"
/>
提前感谢您的帮助。
【问题讨论】:
-
你看过选择器吗?
-
你能详细介绍一下选择器@hoomi吗?
-
在我找教程的时候看看这个(developer.android.com/guide/topics/resources/…)
-
我认为问题出在 isOn 变量中,也许它在等待网络请求或其他东西,这可能是您的麻烦之源,isOn 代表什么剂量?
标签: android button click imageview