Here is my requirement i need to set string from sqlite and to assign it to spinner really confused how to do this when i click edit button here it will go to next activity here i will retrieve all value i have set value to edittext but cannot set value to spinner how can i do this so far what i have tried is:
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());
}
}
how to set that match to adapter company names struggling with this can someonehelp me!!
Aucun commentaire:
Enregistrer un commentaire