I have an app in which I have an ImageView
in that ImageView
I want to show image
from server after 2 seconds
.How can I do that.
Asked
Active
Viewed 634 times
1

Harshad Pansuriya
- 20,189
- 8
- 67
- 95

vishwas
- 251
- 1
- 3
- 16
-
use handler to do so – Vivek Mishra Jul 07 '16 at 07:53
-
have some code sample ....I really apreciate.... – vishwas Jul 07 '16 at 07:54
1 Answers
2
Create a Runnable
that executes the change you want (I suppose it will be changing an ImageView
's bitmap), and post them with delay to the main thread loop, using a Handler
and its postDelayed()
method.
To make it a loop, you could have the runnable
post itself.
UpDate :
This way you can open Activity inside Handler
.
final View imageView = (ImageView) findViewById(R.id.imageView);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final Intent intent = new Intent(LoActivity.this, StartActivity.class);
-- For getting image form ImageView and Pass to Another Activity code --
imageView.buildDrawingCache();
Bitmap image= imageView.getDrawingCache();
Bundle extras = new Bundle();
extras.putParcelable("imagebitmap", image);
intent.putExtras(extras);
-- In upper Bundle you have your bitmap Image --
LoActivity.this.startActivity(intent);
LoActivity.this.finish();
}
});
}
}, 2000);
and In AnotherActivity.java you will get the bitmap
like this way.
Bundle extras = getIntent().getExtras();
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap");
image.setImageBitmap(bmp );
Hope this will help you..

Harshad Pansuriya
- 20,189
- 8
- 67
- 95
-
let suppose three images are added in image view after 2 seconds when ever user click on image view I want to open another activity wit that image details .is this possible ,if yes guide me plsss. – vishwas Jul 07 '16 at 07:58
-
-
-
I want when user click on imageview he will be redirected to another activity with that image that was clicked by him – vishwas Jul 07 '16 at 08:07
-
see i have posted code in that code pass the image bitmap before `startActivity` it will hold your `Image` inside `Intent` and in other Activity you can get it via `Bundle`. – Harshad Pansuriya Jul 07 '16 at 08:09
-
-
@vishwas simple you are getting image from server and then you have to set it to `ImageView` you have code that and get the `Image` from `ImageView` using this code `Bitmap bitmap = ((BitmapDrawable)image.getDrawable()).getBitmap();`. and pass that `bitmap` to `AnotherActivity`. – Harshad Pansuriya Jul 07 '16 at 08:15
-
@vishwas I write almost all code you have add only fetch the image from server and it's work..Now do it Happy Coding... – Harshad Pansuriya Jul 07 '16 at 08:23
-
-
-
https://www.google.co.in/search?q=image+with+arrow+pop+up+window&tbm=isch&tbo=u&source=univ&sa=X&ved=0ahUKEwjh74Cb-uDNAhUKlJQKHbylDPYQsAQIHw&biw=1366&bih=643#imgrc=DS-LHijowFRvjM%3A – vishwas Jul 07 '16 at 08:42
-
I want like yhis pop up over image view showing features about that image text in that pop up will change according to image in imageview – vishwas Jul 07 '16 at 08:43
-
@vishwas see this http://stackoverflow.com/questions/21031488/android-popupwindow-with-tooltip-arrow – Harshad Pansuriya Jul 07 '16 at 08:44
-
@vishwas you can use other answer below have also very nice Answer and it can help you to do that.. – Harshad Pansuriya Jul 07 '16 at 08:51