Reputation: 1274
Below is a method in OnClickListner
. I want to pass first 1=0
, then i=1
likewise.
But below code shows only i=0
;
@Override
public void onClick(View v) {
for(i=0; i<shopTelNos.length;i++){
Toast.makeText(c.getApplicationContext(),"value is : "+i,Toast.LENGTH_SHORT).show();
break;
}
}
});
Help me on this.
Upvotes: 0
Views: 46
Reputation: 142
I think the break is causing to stop after the first iteration on the loop. Try to remove the break and retest. it should do the trick
Upvotes: 1
Reputation: 257
First, either debug or print and check the array and its length to confirm its contents:
Log.i("ShopTel", "Array :" +shopTelNos);
Log.i("ShopTel", "Array size :" +shopTelNos.length);
Second, put a delay in between the toasts. The toasts may be overlapping.
Upvotes: 0
Reputation: 423
Are you sure shopTelNos.length is more than 1? The for loop you have made loops through all the elements in the shopTelNoss array. If there is only one element in that array, it will only display the message once.
Upvotes: 0