0
這是我的需求,我需要從sqlite中設置字符串,並將其分配給微調真的很困惑如何做到這一點,當我點擊編輯按鈕在這裏它將去下一個活動在這裏我將檢索所有值我已設置值edittext但不能設置值spinner我怎麼能做到這一點到目前爲止,我曾嘗試是:如何將字符串值設置爲從微軟的微調?
RequestQueue queue_company_name = Volley.newRequestQueue(getBaseContext());
final ArrayList<Model_Account> arrayobj_company_name = new ArrayList<Model_Account>();
String Url_company_name = "http://xxx/xxx/xxx/AcoountCreatePageLoad.svc/Account/Accouxxxt";
JsonObjectRequest jsonObjRequest_company_name = new JsonObjectRequest(Request.Method.GET, Url_company_name, new JSONObject(),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
String server_response = response.toString();
try {
JSONObject json_object = new JSONObject(server_response);
JSONArray json_array = new JSONArray(json_object.getString("AccountPageLoadAccountListResult"));
for (int i = 0; i < json_array.length(); i++) {
Model_Account model_spinner = new Model_Account();
JSONObject json_arrayJSONObject = json_array.getJSONObject(i);
model_spinner.setName(json_arrayJSONObject.getString("CompanyName"));
model_spinner.setCompanyname(json_arrayJSONObject.getInt("AccountID"));
arrayobj_company_name.add(model_spinner);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(getBaseContext(), error.toString(), Toast.LENGTH_SHORT).show();
}
});
//Creating request queue
queue_company_name.add(jsonObjRequest_company_name);
ArrayAdapter<Model_Account> company_names = new ArrayAdapter<Model_Account>(this, android.R.layout.simple_spinner_dropdown_item, arrayobj_company_name);
spinner_company_name.setAdapter(company_names);
final Bundle extra = getIntent().getExtras();
if (extra != null) {
id = extra.getInt("id");
Cursor edit_accnt = account_sf_db.getData(id);
if (edit_accnt.moveToFirst()) {
do {
compny_group.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.company_groups)));
company_name.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Parent_company)));
addrss1.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Address_line1)));
address_2.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Address_line2)));
address_3.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Address_line3)));
pin_code.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Pincode)));
land_line.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Landline1)));
landline_2.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Landline2)));
url.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Url)));
email.setText(edit_accnt.getString(edit_accnt.getColumnIndex(Model_Account.Landline2)));
String match = edit_accnt.getString(edit_accnt.getColumnIndexOrThrow(Model_Account.Company_name));
Log.e("test",match);
} while (edit_accnt.moveToNext());
}
}
如何設置匹配適配器公司名稱與此掙扎可以someonehelp我!
我這樣做沒有什麼工作 – Yog
這將是因爲你想要設置的字符串的位置將返回-1指示微調沒有該項目 –
你得到-1 – Yog