Re: [android-developers] Problem in loading image on the layout on clicking button.

2010-11-22 Thread alok upadhyay
thanks for the hint!!

On Sat, Nov 20, 2010 at 12:54 AM, TreKing treking...@gmail.com wrote:

  On Wed, Nov 17, 2010 at 12:37 AM, Alok Upadhyay 
 maddy.luck...@gmail.comwrote:

 Problem:i am able to load images in next button click but as i click on
 back button no image got loaded.


 Look at the code you posted:

  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;



 Now ask yourself: What am I doing in case R.id.next that I'm not doing in
 case R.id.back?


 -
 TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
 transit tracking app for Android-powered devices


 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Thanks  Regards
Alok Upadhyay
9555758721

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

Re: [android-developers] Problem in loading image on the layout on clicking button.

2010-11-19 Thread TreKing
On Wed, Nov 17, 2010 at 12:37 AM, Alok Upadhyay maddy.luck...@gmail.comwrote:

 Problem:i am able to load images in next button click but as i click on
 back button no image got loaded.


Look at the code you posted:

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;



Now ask yourself: What am I doing in case R.id.next that I'm not doing in
case R.id.back?

-
TreKing http://sites.google.com/site/rezmobileapps/treking - Chicago
transit tracking app for Android-powered devices

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

[android-developers] Problem in loading image on the layout on clicking button.

2010-11-16 Thread Alok Upadhyay
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en