0
我想通過使用微調控制器來實現用戶搜索。更改基於另一個微調控制器的微調選項
我有車隊和車輛(車隊包含車輛)。我有一個車隊列表作爲一個微調和一個車輛列表作爲另一個。
默認情況下,我希望車隊設置爲「全部」,車輛一個顯示所有車輛(目前情況下),但是當車隊輸入更改爲特定車隊時,比如說fleet1,汽車微調應該相應地更新[這將通過SQLite數據庫搜索實施,但我不認爲這個問題在這裏]。
如何爲艦隊微調器數據更改時創建偵聽器?
vehicleSpinner = (Spinner) findViewById(R.id.vehicleSpinner);
String selected = (String)fleetSpinner.getSelectedItem();
ArrayAdapter<String> adapter5 = null;
if(selected == "All"){
//show all vehicles
adapter5 = new ArrayAdapter<String>(this, R.layout.sherlock_spinner_item, vehicleArrayListString);
}else{
String vehiclesInFleetQuery = "SELECT * FROM " + Database.TABLE_VEHICLE + " WHERE " + Database.COLUMN_FLEET + "='" + selected +"'";
Log.i(TAG,"QUERY: "+ vehiclesInFleetQuery);
Cursor cursor = Database.listOfVehiclesDesired(query);
if(cursor.moveToFirst()){
do {
String addToList = cursor.getString(cursor.getColumnIndex(Database.COLUMN_VEHICLE_ID));
vehicleArrayFleet.add(addToList);
} while (cursor.moveToNext());
}else{//error on fleet search, no vehicles in fleet
vehicleArrayFleet = vehicleArrayListString;
builderContinue.setMessage("Selected Fleet(" + selected + ") had zero associated vehicles").setTitle("Error").show();
}
if (cursor != null && !cursor.isClosed()) {
System.out.println("Closed");
cursor.close();
}
adapter5 = new ArrayAdapter<String>(this, R.layout.sherlock_spinner_item, vehicleArrayFleet);
}
adapter5.setDropDownViewResource(R.layout.sherlock_spinner_dropdown_item);
vehicleSpinner.setAdapter(adapter5);
你有刪除這個問題好,但它沒有做...等我有更好的禮物給你:) :),如果你需要回應我 –
好吧去[這裏](http://stackoverflow.com/問題/ 15457893/java-right-shift-on-negative-number/15457908#15457908) –
再次感謝Grijesh! – benzabill