Android : How to change the image of an ImageView immediately after clicking a button?

on Saturday, September 13, 2014


Probably I am not doing it right. I was trying to change an image right after a button is clicked. But whatever way I follow, it takes about at least 1/1.5 seconds to get the changed image. I thought that might be happening because of the image size. But after reducing the size, still the problem remains. I tried to do as it is said in this link


But no luck. Still the image changes with a delay.


Can someone help me out with the right way?


Here is the code I used to change my image.



portrait.setImageResource(R.drawable.torch1);


after clicking the button, I want immediate change of the resource image.


here is the xml block I used to display the image.



<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"
/>


Thanks in advance for any help.


0 comments:

Post a Comment