मैं AsyncTaks में स्पिनर सामग्री को संशोधित करने का प्रयास करता हूं लेकिन मैं नहीं कर सकता और लॉगकैट लिखा है "09-19 16: 36: 11.189: त्रुटि/त्रुटि (6078): केवल मूल धागा जिसने दृश्य पदानुक्रम बनाया है अपने विचारों को छूएं। "AsyncTask "केवल दृश्य धागा जिसने दृश्य पदानुक्रम बनाया है, उसके विचारों को छू सकता है।"
public class GetGroups extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
Spinner combo = (Spinner) findViewById(R.id.group_combo);
setGroups(combo);
return null;
}
@Override
protected void onPostExecute(Void unused)
{
super.onPostExecute(unused);
Spinner combo = (Spinner) findViewById(R.id.severity_combo);
combo.setSelection(1);
//updateGroups();
//if (!isFinishing())
//{
/*Spinner combo = (Spinner) findViewById(R.id.group_combo);
ProgressBar pg = (ProgressBar) findViewById(R.id.loading_group);
pg.setVisibility(ProgressBar.GONE);
combo.setVisibility(Spinner.VISIBLE);
combo.setSelection(0);*/
//}
}
}
}
और समारोह setGroups है:
public void setGroups(Spinner combo) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(this.object.url);
List<NameValuePair> parameters = new ArrayList<NameValuePair>(2);
parameters.add(new BasicNameValuePair("user", this.object.user));
parameters.add(new BasicNameValuePair("pass", this.object.password));
parameters.add(new BasicNameValuePair("op", "get"));
parameters.add(new BasicNameValuePair("op2", "groups"));
parameters.add(new BasicNameValuePair("other_mode", "url_encode_separator_|"));
parameters.add(new BasicNameValuePair("return_type", "csv"));
parameters.add(new BasicNameValuePair("other", ";"));
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(parameters);
httpPost.setEntity(entity);
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entityResponse = response.getEntity();
String return_api = this.object.convertStreamToString(entityResponse.getContent());
String[] lines = return_api.split("\n");
ArrayList<String> array = new ArrayList<String>();
for (int i= 0; i < lines.length; i++) {
String[] groups = lines[i].split(";", 21);
this.pandoraGroups.put(new Integer(groups[0]), groups[1]);
array.add(groups[1]);
}
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item,
array);
combo.setAdapter(spinnerArrayAdapter);
}
catch (Exception e) {
Log.e("ERROR THE ", e.getMessage());
return;
}
}
क्या गलत है? धन्यवाद।
GetGroups एक आंतरिक वर्ग है में से एक के आधार पर? –
आप क्या करने की कोशिश कर रहे हैं? [केवल मूल बात यह है कि एक दृश्य पदानुक्रम बनाया अपने विचार छू सकता है] (की – Ronnie
संभव डुप्लिकेट http://stackoverflow.com/questions/10497854/only-the-original-thread-that-created-a-view-hierarchy- कैन-टच-इसके-दृश्य) –