Создайте один класс pojo, как
class student{
String id,
String name,
String age,
String titles
}
, теперь замените приведенный ниже код
if(c.moveToFirst()) {
do {
titles.add(c.getString(id) + " \t " + c.getString(name) + " \t " + c.getString(age));
} while (c.moveToNext());
arrayAdapter.notifyDataSetChanged();
lst1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String tt = titles.get(position).toString();
Intent i = new Intent(getApplicationContext(),edit.class);
i.putExtra("age",tt);
startActivity(i);
}
});
на
ArrayList<student> stud = new ArrayList<student>();
if(c.moveToFirst()) {
do {
student stu = new student()
stu.id = c.getString(id);
stu.name = c.getString(name);
stu.age = c.getString(age);
//you need to add the Student object stu not the ArrayList Object stud
stud.add(stu);
titles.add(c.getString(id) + " \t " + c.getString(name) + " \t " + c.getString(age));
} while (c.moveToNext());
arrayAdapter.notifyDataSetChanged();
lst1.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String tt = titles.get(position).toString();
student stu = stud.get(position);
Intent i = new Intent(getApplicationContext(),edit.class);
i.putExtra("age",stu.age);
startActivity(i);
}
});
Выглядит так:
Foo.hello.im_func(bar)
Привет, я Бар.
Полагаю, мне нужно прочитать этот немного сложнее. ..
It happens because python wraps class functions as an "unbound method" which performs this type checking. There's some description of the decisions involved in this here.
Note that this type checking has actually been dropped in python 3 (see the note at the end of that article), so your approach will work there.
Некоторое время назад я размышлял о той же «функции» в Perl на PerlMonks, и общий консенсус заключался в том, что, пока он работает (как в Python), вы не должны делать то, что способ.