Note that there are some explanatory texts on larger screens.

plurals
  1. POrunOnUiThread crash when calling in asyntask
    text
    copied!<p>im using runOnUiThread to show UI fromasyntask but my app is crash please help me what do i do? how do i showmy Ui on postexecute directly??? im so confuse why runOnUiThread is crash???? how do i show my textview values on screen??</p> <pre><code> public class fifthscreen extends Activity { String num = null; // TextView ingredient; // TextView ingredient; View row4; int IOConnect = 0; View row3; String status; HorizontalListView listview; CategoryListAdapter3 cla; String DescriptionAPI; TextView txt1, txt2, txt3; ImageView img1; String URL, URL2; String SelectMenuAPI; static ArrayList&lt;Long&gt; Category_ID = new ArrayList&lt;Long&gt;(); static ArrayList&lt;String&gt; Category_name = new ArrayList&lt;String&gt;(); static ArrayList&lt;String&gt; Category_image = new ArrayList&lt;String&gt;(); public static String allergen2; TableLayout table; String name; LinearLayout table3; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fifthscreen); table = (TableLayout) findViewById(R.id.table2); table3 = (LinearLayout) findViewById(R.id.table3); } void clearData() { Category_ID.clear(); Category_name.clear(); Category_image.clear(); } public class getDataTask extends AsyncTask&lt;Void, Void, Void&gt; { getDataTask() { } @Override protected void onPreExecute() { // TODO Auto-generated method stub } @Override protected Void doInBackground(Void... arg0) { // TODO Auto-generated method stub return null; } @Override protected void onPostExecute(Void result) { parseJSONData(); } } public void parseJSONData() { SelectMenuAPI = Utils.dishdescription; URL = SelectMenuAPI; URL2 = URL.replace(" ", "%20"); try { HttpClient client = new DefaultHttpClient(); HttpConnectionParams .setConnectionTimeout(client.getParams(), 15000); HttpConnectionParams.setSoTimeout(client.getParams(), 15000); HttpUriRequest request = new HttpGet(URL2); HttpResponse response = client.execute(request); InputStream atomInputStream = response.getEntity().getContent(); BufferedReader in = new BufferedReader(new InputStreamReader( atomInputStream), 8192); String line; String str = ""; while ((line = in.readLine()) != null) { str += line; } JSONObject json2 = new JSONObject(str); JSONObject school3 = json2.getJSONObject("dish_nutrition"); //final TableLayout table = (TableLayout) findViewById(R.id.table2); for (int j = 0; j &lt; school3.length(); j++) { String s = String.valueOf(j + 1); row3 = getLayoutInflater().inflate(R.layout.rows, null); ((TextView) row3.findViewById(R.id.localTime)).setText(school3 .getJSONObject(s).getString("qty")); ((TextView) row3.findViewById(R.id.apprentTemp)) .setText(school3.getJSONObject(s).getString("name")); //fifthscreen.this.runOnUiThread(new Runnable() { //public void run() { table.addView(row3); //} //}); } //final LinearLayout table3 = (LinearLayout) findViewById(R.id.table3); JSONArray school5 = json2.getJSONArray("dish_ingredient"); for (int i = 0; i &lt; school5.length(); i++) { row4 = getLayoutInflater().inflate(R.layout.row2, null); ((TextView) row4.findViewById(R.id.name)).setText(school5 .getJSONObject(i).getString("name")); ((TextView) row4.findViewById(R.id.subingredients)) .setText(school5.getJSONObject(i).getString( "sub_ingredients")); // table3.addView(row2); //fifthscreen.this.runOnUiThread(new Runnable() { // public void run() { table3.addView(row4); //} //}); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block IOConnect = 1; e.printStackTrace(); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload