Issue
I want to display a textView in popup Window when I click a View , but the calculation needs time, so I make the calculation in AsyncTask, but how to show the popup Window immediately after the AsyncTask process is finished?
public void onClick(View widget) {
MyAsyncTask asyncTask = new MyAsyncTask(new AsyncResponse() {
@Override
public void processFinish(Object output) {
meaning_result = (String) output;
}
});
asyncTask.execute("xxxxx");
showPopupWindow(widget);
}
This is my first thought but the showPopupWindow(widget)
executes first and the meaning_result
has not assigned yet. How to make showPopupWindow(widget)
runs once the meaning_result is assigned?
Solution
Try something like this :
public void showPopUp(final View widget){
runOnUiThread(new Runnable() {
@Override
public void run() {
showPopupWindow(widget);
}
});
}
and :
public void onClick(final View widget) {
MyAsyncTask asyncTask = new MyAsyncTask(new AsyncResponse() {
@Override
public void processFinish(Object output) {
meaning_result = (String) output;
showPopUp(widget);
}
});
asyncTask.execute("xxxxx");
}
Hope this helps
Answered By - Benkerroum Mohamed
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.