i want to compare arraylist with a textview, when the value of arraylist and textview is match/same, i want to show the index of the arraylist..
this is my code
TextView namamenu2=(TextView)findViewById(R.id.nama_menu2);
String nama_menu_upd = namamenu2.getText().toString();
for(MenuInputClass mic2 : results) {
String comp=mic2.getNama_menu();
if(nama_menu_upd.equals(comp))
{
int compIndex=results.indexOf(comp);
Toast.makeText(Appetizer_Activity.this,compIndex, Toast.LENGTH_LONG).show();
}
}
MenuInputClass
public class MenuInputClass {
private String nama_menu;
private String jumlah_menu;
public void setNama_menu(String nama_menu) {
this.nama_menu=nama_menu;
}
public String getNama_menu() {
return (nama_menu);
}
}
when i show compIndex on Toast, its always show -1.But when i try to show the size of result , its show correct size.how can i fix this?