是否有可能在装载Android的下拉框使用一个SQLite表中的项目?怎么样? [英] Is it possible to load a dropdown box in Android with items from a SQLite table? How?
本文介绍了是否有可能在装载Android的下拉框使用一个SQLite表中的项目?怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我重新编码为Android平台的应用程序。我想有填充在用户可编辑的表项的下拉框。这个很容易做到,在Android的?
I'm recoding an application for the Android platform. I'd like to have a dropdown box populated with items in a user editable table. Is this "easily done" in Android?
推荐答案
是的,它很容易被利用微调完成。
yes,it is easily done by using spinner.
尝试以下code
int i=0;
Spinner sp1=(Spinner)findViewById(R.id.spinner1);
Dbhelper db1=new Dbhelper(this);
SQLiteDatabase db=db1.getReadableDatabase();
Cursor c1=db.rawQuery("select accNo from Account4 where bankName='"+str+"'",null);
acc=new String[c1.getCount()];
while(c1.moveToNext()){
acc[i]=c1.getString(c1.getColumnIndex("accNo"));
i++;
}
ArrayAdapter<String> adp=new ArrayAdapter<String(this,android.R.layout.simple_spinner_dropdown_item,acc);
sp1.setAdapter(adp);
c1.close();
db.close();
这篇关于是否有可能在装载Android的下拉框使用一个SQLite表中的项目?怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文