Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If the component to update is the component that starts the update Job (through AsyncTask or Service), you should probably use an inner <a href="http://developer.android.com/reference/android/os/AsyncTask.html" rel="nofollow noreferrer">AsyncTask</a><br /></p> <p>AsyncTask offers you two posibilites to update the UI :</p> <ul> <li>To update the UI in parallel with the task executed in doInBackground() (e.g. to update a ProgressBar), you'll have to call publishProgress() inside the doInBackground() method. Then you have to update the UI in the onProgressUpdate() method.</li> <li>To update the UI when the task is done, you have to do it in the onPostExecute() method.</li> </ul> <p>see :<br /> <a href="http://developer.android.com/reference/android/os/AsyncTask.html#doInBackground%28Params...%29" rel="nofollow noreferrer">doInBackground()</a><br /> <a href="http://developer.android.com/reference/android/os/AsyncTask.html#publishProgress%28Progress...%29" rel="nofollow noreferrer">publishProgress()</a><br /> <a href="http://developer.android.com/reference/android/os/AsyncTask.html#onProgressUpdate%28Progress...%29" rel="nofollow noreferrer">onProgressUpdate()</a><br /> <a href="http://developer.android.com/reference/android/os/AsyncTask.html#onPostExecute%28Result%29" rel="nofollow noreferrer">onPostExecute()</a><br /></p> <p><b>Edit :</b></p> <pre><code>public class Home extends Activity implements OnClickListener { private Button mButton; private TextView mTextView; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_layout); mButton = (Button) findViewById(R.id.myButton); mTextView = (TextView) findViewById(R.id.myTextView); } @Override public void onClick(View view) { switch (view.getId()) { case R.id.myButton: (new MyAsyncTask()).execute(); break; default: break; } } private class MyAsyncTask extends AsyncTask&lt;String, int[], Boolean&gt; { /** This method runs on a background thread (not on the UI thread) */ @Override protected String doInBackground(String... params) { for (int progressValue = 0; progressValue &lt; 100; progressValue++) { publishProgress(progressValue); } } /** This method runs on the UI thread */ @Override protected void onProgressUpdate(Integer... progressValue) { // TODO Update your ProgressBar here mTextView.setText("Updating : " + progressValue + "/100"); } /** * Called after doInBackground() method * This method runs on the UI thread */ @Override protected void onPostExecute(Boolean result) { // TODO Update the UI thread with the final result mTextView.setText("Update complete !"); } } } </code></pre> <p>You can find another example <a href="https://stackoverflow.com/questions/10316335/how-access-parent-class-view-from-callback-function-in-asynctask/10321332#10321332">here</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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