开发者

How can I update textview text using async.process in Android?

I want to update my text view when ever loop is on doinbackground() {} runs. I want to update my te开发者_C百科xt view with the counter of the loop that is running in the background

protectedBooleandoInBackground(String...args)
{
    startManagingCursor(cursor);
    if (cursor.moveToFirst() ) 
    { 
      do {
          publishProgress();
          }
      while( cursor.moveToNext() );
    }
    else {
    }

    try
      {
        if (writer!=null)
           writer.close();
      }
    catch(IOExceptione) 
    {
        Log.w("Test",e.toString());
    }
    end loop
    return null;
}


protected void onProgressUpdate(String...values)
{
    Log.i("test..","ramjit");
}

I'm not able to enter my onProgressUpdate() method. So how update textview when loop is running on doinbackground();


Directly from the AsyncTask page - http://developer.android.com/reference/android/os/AsyncTask.html

Your publishProgress may not working as you aren't passing along any values. Try to call publisherProgress(stringHere)

Then in onProgressUpdate use the data from the values array. As onProgressUpdate is run on the UI thread it's safe to just update a textview as normal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜