hii, in my android application there are number of images in drawable
folder. in my layout two buttons: back and forward button.on clicking
next and back buttons different-2 image get loaded on the same
layout(common for all images). Problem:i am able to load images in
next button click but as i click on back button no image got loaded.my
code is as:

public class SequencerActivity extends Activity implements
OnClickListener
{ private int imageCounter = 0; private ImageView imageLoader;

private int[] imageList = {R.drawable.image_wo_lbl_0,
R.drawable.image_wo_lbl_1, R.drawable.image_wo_lbl_2,
R.drawable.image_wo_lbl_3, R.drawable.image_wo_lbl_4,
R.drawable.image_wo_lbl_5,
        R.drawable.image_wo_lbl_6, R.drawable.image_wo_lbl_8,
R.drawable.image_wo_lbl_9,R.drawable.image_wo_lbl_10,
R.drawable.image_wo_lbl_11};
@Override
public void onCreate(Bundle savedInstanceState)
{
    setContentView(R.layout.parent_frame);//this one is the common
parent layout for all image views
    super.onCreate(savedInstanceState);

    imageLoader = (ImageView) findViewById(R.id.imageLoader);


    ImageButton next = (ImageButton) findViewById(R.id.next);
    ImageButton back = (ImageButton) findViewById(R.id.back);
    next.setOnClickListener(this);
    back.setOnClickListener(this);
    //show the default image
    this.loadImage(imageList[imageCounter]);

}
@Override
public void onClick(View v)
{
    int imagePath = 0;
    // TODO Auto-generated method stub
    switch (v.getId())
    {
    case R.id.next:
        Log.i("Tag","tag");
        if(imageCounter < 25)//if(imageCounter < arrayList.length())
        {
            imageCounter++;
            imagePath = imageList[imageCounter];
        }
        break;
    case R.id.back:
        if(imageCounter > 0)
        {
            imagePath = imageList[imageCounter];
        }
        break;
    }
    this.loadImage(imagePath);

}

private void loadImage(int imagePath)
{
    imageLoader.setImageResource(imagePath);

}

 hii, in my android application there are number of images in drawable
folder. in my layout two buttons: back and forward button.on clicking
next and back buttons different-2 image get loaded on the same
layout(common for all images). Problem:i am able to load images in
next button click but as i click on back button no image got loaded.my
code is as:

public class SequencerActivity extends Activity implements
OnClickListener
{ private int imageCounter = 0; private ImageView imageLoader;

private int[] imageList = {R.drawable.image_wo_lbl_0,
R.drawable.image_wo_lbl_1, R.drawable.image_wo_lbl_2,
R.drawable.image_wo_lbl_3, R.drawable.image_wo_lbl_4,
R.drawable.image_wo_lbl_5,
        R.drawable.image_wo_lbl_6, R.drawable.image_wo_lbl_8,
R.drawable.image_wo_lbl_9,R.drawable.image_wo_lbl_10,
R.drawable.image_wo_lbl_11};
@Override
public void onCreate(Bundle savedInstanceState)
{
    setContentView(R.layout.parent_frame);//this one is the common
parent layout for all image views
    super.onCreate(savedInstanceState);

    imageLoader = (ImageView) findViewById(R.id.imageLoader);


    ImageButton next = (ImageButton) findViewById(R.id.next);
    ImageButton back = (ImageButton) findViewById(R.id.back);
    next.setOnClickListener(this);
    back.setOnClickListener(this);
    //show the default image
    this.loadImage(imageList[imageCounter]);

}
@Override
public void onClick(View v)
{
    int imagePath = 0;
    // TODO Auto-generated method stub
    switch (v.getId())
    {
    case R.id.next:
        Log.i("Tag","tag");
        if(imageCounter < 25)//if(imageCounter < arrayList.length())
        {
            imageCounter++;
            imagePath = imageList[imageCounter];
        }
        break;
    case R.id.back:
        if(imageCounter > 0)
        {
            imagePath = imageList[imageCounter];
        }
        break;
    }
    this.loadImage(imagePath);

}

private void loadImage(int imagePath)
{
    imageLoader.setImageResource(imagePath);

}
}

i am thinking there is some logical problem in couter increment /
decrement.i have used hard code 25 but just for test.i will use
ArrayList.length(). help please.Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to