Issue
I have three array
int[] image = {R.drawable.img1,R.drawable.img2} int[] sound= {R.raw.m1,R.raw.m2} String[] nom ={"el1","el2"}
I tryed to change a view with imageview, text from those array when click button but i got only the last value from three array these my method i call when onclick method
private void updateData() {
while (i<nom.length) {
ImageView.setImageResource(image[i]);
textview.setText(nom[i]);
mysong = MediaPlayer.create(Activity.this, sound[i]);
mysong.start();
i++;
}
}
Solution
Try this....
int anInt = 0;
And After OnClick
private void updateData() {
if (anInt < image.length - 1) {
anInt++;
} else {
anInt = 0;
}
ImageView.setImageResource(image[anInt]);
textview.setText(nom[anInt]);
mysong = MediaPlayer.create(Activity.this, sound[anInt]);
mysong.start();
}
Note : Make Sure Your All Three Array Same Size...
Answered By - Jay Panchal
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.