开发者

Android 2.2 Implements Runnable Public void run() not being called

开发者 https://www.devze.com 2023-04-06 15:26 出处:网络
I have the following:- public class resApp extends MapActivity implements Runnable { public void run() {

I have the following:-

public class resApp extends MapActivity implements Runnable {

    public void run() {
        searchImage.setVisibility(View.GONE);
    }

}

I also have a background thread that runs before this but that seems to run ok.

When i run the app the run() never gets called.

Can you help? This code did work about 6 months ago but the devic开发者_开发技巧e was 2.1.

Thanks

Chris


edit

I had already implemented

 private Handler handler;

 handler = new Handler() {
 @Override
public void handleMessage(Message msg) {
    if (msg.toString().equalsIgnoreCase("1")) {
    ad.dismiss();
    } else {
    pd.dismiss();
    }
}
 };

as an example and I already have an asynchronous task that runs in the back ground and in 2.1 I could have getters and setters in there. I have now had to pull these out and put them into the run() method as 2.2 doesn't like setting onclicklistener in an async task. All I need to do is call the run() method on post execute but have tried everything:-

protected void onPostExecute(Object result) {
// Pass the result data back to the main activity
if (dialog != null) {
    resApp.this.dialog.dismiss();
}
}

Could I just do:-

 handler = new Handler() {
    @Override
public void handleMessage(Message msg) {
    this.resApp.run();
}
 };


You can call the run() method by using Handler.

Handler myHandler = new Handler();
resApp myObj;

And call it by using myHandler.post(myObj);

0

精彩评论

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