I\'m trying to implement a simple activity that will let user to insert a password. I\'ve a gridview with the 9 images to use and 4 imageviews that will be the selected images (
Approach 1)
Let the thread sleep in doInBackground
, but change the resource in
@Override
protected void onPostExecute(Void aVoid) {}
method of the AsyncTask. This method has access to the UI thread.
Approach 2)
Another way might be to use
YourActivity.this.runOnUiThread(new Runnable() {
public void run() {
YourActivity.this.passField1.setImageResource(R.drawable.e00)
}
});
(called from doInBackground) where passfield is not a local variable but class variable.
But approach 1 is the preferred way, I suggest you try that way first.
I think you would better use View.postDelayed(Runnable, long) in the onClickListener of your ImageViews to do this.