Android image “viewer” app?

As a newbie myself I've been working with this and it's very simple. Here is some code (maybe there is a better way but this is the way I figured out how to do it): package com. Imageviewexample; import android.app.

Activity; import android.os. Bundle; import android.view. View; import android.view.View.

OnClickListener; import android.widget. Button; import android.widget. ImageView; public class ImageViewExample extends Activity implements OnClickListener { /** Called when the activity is first created.

*/ int image_index = 0; private static final int MAX_IMAGE_COUNT = 3; private Integer mImageIds = { R.raw. Image1, R.raw. Image2, R.raw.

Image3 }; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Main); Button btnPrevious = (Button)findViewById(R.id.

Previous_btn); btnPrevious. SetOnClickListener(this); Button btnNext = (Button)findViewById(R.id. Next_btn); btnNext.

SetOnClickListener(this); showImage(); } private void showImage() { ImageView imgView = (ImageView) findViewById(R.id. Myimage); imgView. SetImageResource(mImageIdsimage_index); } public void onClick(View v) { switch (v.getId()) { case (R.id.

Previous_btn): image_index--; if (image_index == -1) { image_index = MAX_IMAGE_COUNT - 1; } showImage(); break; case (R.id. Next_btn): image_index++; if (image_index == MAX_IMAGE_COUNT) { image_index = 0; } showImage(); break; } } } And this is the main. Xml :?

Xml version="1.0" encoding="utf-8"?

As a newbie myself I've been working with this and it's very simple. Here is some code (maybe there is a better way but this is the way I figured out how to do it): package com. Imageviewexample; import android.app.

Activity; import android.os. Bundle; import android.view. View; import android.view.View.

OnClickListener; import android.widget. Button; import android.widget. ImageView; public class ImageViewExample extends Activity implements OnClickListener { /** Called when the activity is first created.

*/ int image_index = 0; private static final int MAX_IMAGE_COUNT = 3; private Integer mImageIds = { R.raw. Image1, R.raw. Image2, R.raw.

Image3 }; @Override public void onCreate(Bundle savedInstanceState) { super. OnCreate(savedInstanceState); setContentView(R.layout. Main); Button btnPrevious = (Button)findViewById(R.id.

Previous_btn); btnPrevious. SetOnClickListener(this); Button btnNext = (Button)findViewById(R.id. Next_btn); btnNext.

SetOnClickListener(this); showImage(); } private void showImage() { ImageView imgView = (ImageView) findViewById(R.id. Myimage); imgView. SetImageResource(mImageIdsimage_index); } public void onClick(View v) { switch (v.getId()) { case (R.id.

Previous_btn): image_index--; if (image_index == -1) { image_index = MAX_IMAGE_COUNT - 1; } showImage(); break; case (R.id. Next_btn): image_index++; if (image_index == MAX_IMAGE_COUNT) { image_index = 0; } showImage(); break; } } } And this is the main.xml.

This works perfectly. What is driving me crazy is that my 3 or 4 test projects essentially did this exactly the same way, but they would either forceclose or not work some other way. Thank you for saving me from tearing my hair out.

The part I see different from mine is the onClickListener, could you why it has to be set to "this", just so I can try get a more complete understanding. Thanks again. – Hamid Oct 4 '10 at 10:06 Being new to Android, I really cannot explain why it has to be set to "this".

I think the "this" just references your class, or main activity. Like in the above example, "this" could be replaced by "ImageViewExample. This" and it would work the same.

I learned the above from reading developer.android. Com/guide/topics/ui/ui-events. Html – ShadowGod Oct 4 '10 at 21:59 Thanks again.

Most helpful and kind. – Hamid Oct 5 '10 at 17:48 Very helpful for beginners. – Kon Jul 22 at 13:15.

M_vwImage = (ImageView) findViewById(R.id. Drawable image = getResources(). Button startButton = (Button) findViewById(R.id.

Button leftButton = (Button) findViewById(R.id. Drawable imagePrev = getResources(). PicPrevItem = (ImageAdapter.

PicNextItem = (ImageAdapter. Button rightButton = (Button) findViewById(R.id. Drawable imageNext = getResources().

PicNextItem = (ImageAdapter. PicPrevItem = (ImageAdapter. Xml version="1.0" encoding="utf-8"?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions