我想获取函数返回值的索引,但它只给我 -1 值。
ArrayList<categoryoptions_class> arrayList;
rb = new RadioButton[arrayList.size()];
for (int i = 0; i < arrayList.size(); i++) {
rb[i] = new RadioButton(detail_activity_rb.this);
rb[i].setPadding(5,5,5,5);
rb[i].setId(arrayList.get(i).getId());
rb[i].setTag(arrayList.get(i).getValue());
rb[i].setText(arrayList.get(i).getCategory_opt_name());
String a = checkdata(cat_id, rb[i].getId(), i);
// this 'a' is returning perfect value but when i am trying to get the index of the value in a it gives me only -1;
int sa = Arrays.asList(arrayList).indexOf(a);
Toast.makeText(detail_activity_rb.this, sa + " :val",
Toast.LENGTH_LONG).show();
// int sa = i;
if (i == sa) {
rb[i].setChecked(true);
}
rg.setPadding(5,5,5,5);
rg.addView(rb[i]);
checkpos(i,i);
}
public String checkdata(int cat_ids, int optids, int ia) {
String a = cat_ids + "";
String b = optids + "";
String c = ia + "";
String aa = a + b;
Cursor cursor;
// Toast.makeText(getApplicationContext(),aa,Toast.LENGTH_LONG).show();
if(cat_type.equals("rb1"))
{
cursor = dbController.getdata("SELECT * FROM store_values WHERE catopt_id = '"+cat_ids+"';");
}
else
{
cursor = dbController.getdata("SELECT * FROM store_values WHERE catopt_id = '"+aa+"';");
}
// arrayList.clear();
if (cursor.getCount() != 0)
{
String val = "";
while (cursor.moveToNext())
{
val = cursor.getString(8);
}
//Toast.makeText(detail_activity_rb.this,"H",Toast.LENGTH_LONG).show();
return val;
}
else
{
return "not";
}
}
明月笑刀无情
FFIVE
largeQ
相关分类