先生,我在视图中有两个微调器,微调器值来自sqlite manager数据库保存在资源文件夹中...先生我想要从第一个微调器中选择城市然后根据城市选择位置显示在第二个微调器上。因为我选择了“noida”然后位置属于noida populate on spinner2我发送代码为你方便...看它通过pls ....... notepadv3.java是....
**spinner.setOnItemSelectedListener(
new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent,
View view, int position, long id) {
ArrayAdapter adapter2 = new ArrayAdapter<String>(gqMain.this, android.R.layout.simple_spinner_item);
adapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(adapter2);
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}**
setResult(RESULT_OK);
}
});
try{
**Cursor cur1 = mDbHelper.getloc(cabbookingapplication.Selection);
this.startManagingCursor(cur1);
int accountnameIndex = cur1.getColumnIndexOrThrow("locationName");
if(cur1.moveToFirst()){
do{
//adapterForSpinner.add(c.getString(firstnameColumnIndex) + "aged " + c.getShort(ageColumnIndex));
adapter2.add(cur1.getString(accountnameIndex));
} while(cur1.moveToNext());**
}
在databasehelperclass中我的getloc()是......
**public Cursor getloc(String selection)
{
String myPath = DB_PATH + DB_NAME;
myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
Cursor cur1;
// gqMain gq= new gqMain();
//String ssss =gq.s11;
// String saa = cabbookingapplication.Selection;
// String sql = " select CityType.rowid from CityType where CityType.cityName = "+saa;
String sql = "SELECT CityType.rowid, Location.locationName FROM Location, CityType " +
"WHERE Location.cityId = CityType.rowid " +
"AND CityType.cityName ='"+selection+"'";
//cur1 = myDataBase.rawQuery(
// " SELECT locationName FROM Location WHERE cityId in (" +sql+ ")",null);
Log.i("saurabh trivedi",sql);
cur1 = myDataBase.rawQuery(
sql, null);
cur1.moveToFirst();
return cur1;**
}