Updating main thread tablelayout from async thread
<p>I have a problem with updating my table-layout from my async class.
MY async class is fetching XML data so I don't block the main thread. My logs show the XML data is coming through but I don't know how to update my view with the data.</p>

<p>So I am attempting to put the data in tablerows and add the rows to the TableLayout but the logs show errors suggesting the Async class is not allowed to update my TableLayout view.</p>

<p>My code is as follows:</p>

<pre><code>public class RemotePrimary extends Activity {

private static String SERVER_PATH   =   "http://test2.icerge.com/";
private static String XML_FILE1     =   "samplexml";

//private static String SERVER_PATH =   "http://tqs.mamlambo.com/";
//private static String XML_FILE1       =   "scores.jsp";

private String[] data               =   new String[10];

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    TableLayout datatable           =   (TableLayout)findViewById(R.id.TableLayout_data);

    Downloader downloader   =   new Downloader();
    downloader.execute(SERVER_PATH + XML_FILE1, datatable);

}

private class Downloader extends AsyncTask&lt;Object, String, Boolean&gt;{

    TableLayout table;

    @Override
    protected Boolean doInBackground(Object... params) {
        // TODO Auto-generated method stub
        String path             =   (String)params[0];
        table                   =   (TableLayout)params[1];

        XmlPullParser xmldata   =   null;
        try {
            URL serverPath      =   new URL(path);
            xmldata             =   XmlPullParserFactory.newInstance().newPullParser();
            xmldata.setInput(serverPath.openStream(), null);
            addRecord(xmldata, table);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return true;
    }

    @Override
    protected void onProgressUpdate(String... values) {
        // TODO Auto-generated method stub
        //super.onProgressUpdate(values);
    }

    private boolean addRecord(XmlPullParser data, TableLayout table){

        int eventType                   =   -1;
        boolean bFoundScores            =   false;


        //find some records from xml
        while(eventType != XmlResourceParser.END_DOCUMENT){
            if( eventType == XmlResourceParser.START_TAG ){
                //get the name of the tag(eg scores or score)
                String strName  =   data.getName();
                if( strName.equals("node") ){
                    bFoundScores            =   true;
                    String scoreValue       =   data.getAttributeValue(null, "Title");
                    String scoreRank        =   data.getAttributeValue(null, "Type");
                    String scoreUserName    =   data.getAttributeValue(null, "Nid");
                    Log.e("ADDING: ", scoreValue);
                    //Log.e("RETRIEVED", "collected : "+scoreValue+", "+scoreRank+", "+scoreUserName);
                    //publishProgress(scoreValue, scoreRank, scoreUserName);

                    TableRow newRow     =   new TableRow(RemotePrimary.this);
                    TextView rowText    =   new TextView(RemotePrimary.this);
                    rowText.setText(scoreValue);
                    newRow.addView(rowText);
                    table.addView(newRow);
                }
            }
            try {
                eventType   =   data.next();
            } catch (XmlPullParserException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }



        return true;
    }

    @Override
    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
    }

    @Override
    protected void onPostExecute(Boolean result) {
        // TODO Auto-generated method stub
        super.onPostExecute(result);
    }

}//close Downloader class
</code></pre>

<p>}//close RemotePrimary class</p>

<p>It's a bit much I know but I'll appreciate any help.</p>

<p>Thanks a great deal :-)</p>
