开发者

Selecting thumbnail and viewing full screen

I have my app working where it comes to a screen with 6 thumbnails. The user will select 开发者_如何学编程one and the next screen is a full image. I've accomplished this through an OnClickListener to call a new activity/xml (I'm new at this, sorry if my terminology is a little off).

My question is: is there a way to avoid creating 6 activty/xml (one for each thumbnail)? ultimately, my app will have about 40 thumbnails that can be selected for full screen view.

I've been trying to follow examples online where it appears that the code is presenting the full image within java instead of referencing an xml file. I've also seen use of Bitmap and BitmapFactory. Is this the way to go?

If the full screen image can be created dynamically within java, will the Back button still work to the user back to the screen with 6 thumbnails?

thanks, J


The simplest approach to take is to pass a reference to the image in the intent you use to launch the full-screen activity.

You can use the BitmapFactory to create a Bitmap, and then update the ImageView (or however you're displaying the image) from the loaded bitmap.

Using this approach, the back button will still work normally, but you'll only need one activity to display the full-screen image.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜