我试图从mysql数据库填充微调器,但微调器上没有显示任何内容。当我查看日志时,它显示 Attempted to finish an input event but the input event receiver has already been disposed.
这是我的代码,我不知道哪部分错了。
请帮帮我!谢谢您
我的数组如下所示:
{"result":[{"id_jenis_user":"1","jenis_user":"Tenant"},{"id_jenis_user":"2","jenis_user":"Pemilik Acara"}]}
活动.java
public class RegisterActivity extends AppCompatActivity {
Spinner sp_daftar_sbg;
//An ArrayList for Spinner Items
private ArrayList<String> jenis_user_list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
jenis_user_list = new ArrayList<String>();
sp_daftar_sbg = (Spinner)findViewById(R.id.sp_daftar_sbg);
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST,
Server.DATA_URL, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray jsonArray = response.getJSONArray("result");
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String jenis_user = jsonObject.optString(Server.TAG_JENIS_USER);
jenis_user_list.add(jenis_user);
ArrayAdapter<String> jenisuserAdapter = new ArrayAdapter<>(RegisterActivity.this,
android.R.layout.simple_spinner_item, jenis_user_list);
jenisuserAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp_daftar_sbg.setAdapter(jenisuserAdapter);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonObjectRequest);
}
暂无答案!
目前还没有任何答案,快来回答吧!