int count = cursor.getCount();
gsname = new String[count];
BaseAdapter ba = new BaseAdapter() {
@Override
public int getCount() {
// 指定一共包含10个选项
return gsname.length;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
// 重写该方法,该方法返回的View将作为列表框的每项
@Override
public View getView(int position, View convertView, ViewGroup parent) {
TextView text = new TextView(Tianjiac.this);
text.setText(gsname[position]);
text.setTextSize(20);
text.setTextColor(R.color.red);
return text;
}
};
gsmc.setAdapter(ba);
gsmc.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
gs = gsname[arg2];
String selectStr2 = "select pername,tel from guke where comname='"
+ gs + "'";
Cursor cursor2 = sDatabase.rawQuery(selectStr2, null);
cursor2.moveToFirst();
String name = null;
String tel = null;
do {
try {
name = cursor2.getString(0);
tel = cursor2.getString(1);
System.out.println("3333333333333333333333");
} catch (Exception e) {
// TODO: handle exception
name = "";
tel = "";
}
} while (cursor2.moveToNext());
lxr.setText(name);
lxdh.setText(tel);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
看到的一段安卓代码不解,编译环境eclipse,不明白里面BaseAdapter类是什么意思,也搜索了一些资料但是总是弄不明白,求大神帮忙,非常感谢