In the below code i got the value from the database and display in the spinner.And on click of the value in spinner some data must be display but my problem is it display only last row of the data. If you help me it would my pleasure.
SpSites.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
Object itemName = SpSites.getSelectedItem();
String strselectedName = itemName.toString();
for(int i = 0; i < siteName.length; i++){
if(siteName[i].equalsIgnoreCase(strselectedName)){
detailEmployee = gd.selectPhoneDirectory(siteId[i]);//detailEmployee is string array
//Toast.makeText(Directory.this,detailEmployee[i], Toast.LENGTH_LONG).show();
}
for(int j = 0;j<detailEmployee.length;j++){
Toast.makeText(Directory.this,detailEmployee[j], Toast.LENGTH_LONG).show();
System.out.println("Data :"+detailEmployee[j]);
}
}
}
Everything is being shown at the same place. You only see the last element because its showing on top of the others. Use a string builder to concstenate all the items in the last for, and then do a single Toast.show()