protected Void doInBackground(Void... params) {
details = new ArrayList<Details>();
jsonobject = JSONfunctions
.getJSONfromURL(url);
try {
// Locate the NodeList name
jsonarray = jsonobject.getJSONArray("results");
for (int i = 0; i < jsonarray.length(); i++) {
jsonobject = jsonarray.getJSONObject(i);
Details detailAll = new Details();
detailAll.setResType(jsonobject.optString("resType"));
detailAll.setName(jsonobject.optString("resName"));
detailAll.setUrl(jsonobject.optString("resLink"));
details.add(detailAll);
}
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void args) {
直到现在我在微调器中解析JSON对象,我想在水平滚动视图中显示它们.Means字符串将显示在文本视图中,而不是在微调器中
感谢
// TextView textView =(TextView)findViewById(R.id.textView);
MaterialSpinner mySpinner = (MaterialSpinner) findViewById(R.id.spin);
mySpinner.setHint("My liked video is ");
nameList = new ArrayList<String>();
for (Details bean : details) {
nameList.add(bean.getResType());
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(DetailsActivity.this,
android.R.layout.simple_spinner_item, nameList);
adapter
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mySpinner.setAdapter(adapter);
}
答案 0 :(得分:1)