android:onProgressUpdate(Asynctask)停止滚动Scrollview

时间:2013-10-25 11:37:50

标签: android android-asynctask scroll scrollview

我有一个Asynctask,它应该使用onProgressUpdate将Rowlayout添加到Tablelayout,它位于Scrollingview中。在Asynctask工作期间,行被添加到tablelayout,一切都很好。但是在Asynctask工作期间我无法滚动Scrollview,虽然我看到添加的行。如果Asynctask已经完成,我只能滚动。

的AsyncTask

  private class DownloadWebPageTask extends AsyncTask<Integer, String, String> 
  {
    @Override
    protected String doInBackground(Integer... params) {        
        Integer k = 0;
        for(int i = 0; i < 100; i++)
        {
            if(i == 80)
            {
                System.out.println("Debug Breakpoint");
            }
            publishProgress("hey");
        }       
        return k.toString();
    }
    @Override
    protected void onProgressUpdate(String... ProduktListe)
    {
        writeSomeThing();
    }
    @Override
    protected void onPostExecute(String result) 
    {             

    }   
  }

创建行

  public void writeSomeThing() 
  {     
            //make here breakpoint
            MainActivity context = this;


            TableLayout searchBody = (TableLayout) context.findViewById(R.id.tableLayout);

            LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);

            TableRow rowView = (TableRow)inflater.inflate(R.layout.reintuding, null);

            searchBody.addView(rowView);    
  }

main_activity.xml

<?xml version="1.0" encoding="utf-8"?>

    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/Gesamt"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#0099cc" >

        <ScrollView
            android:id="@+id/scroll"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:fadingEdge="vertical"
            android:minHeight="610dp">

            <TableLayout
                android:id="@+id/tableLayout"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true"
                android:fitsSystemWindows="true"
                android:stretchColumns="0" >

            </TableLayout>


        </ScrollView>

    </RelativeLayout>

reintuding.xml

<?xml version="1.0" encoding="utf-8"?>
<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button" />

</TableRow>

0 个答案:

没有答案