0

有改变图像的方法setimage ()setWeather ()我想成为一个补间动画,何时setweathersetimage在服务上被调用。我需要你的帮助。

  @Override
        public void onCreate() {
            super.onCreate();
            mIv = new ImageView(this);
            mIv.setImageResource(R.drawable.ic_launcher);
            mContentResolver = getContentResolver();
            mProviderObserver = new ContentObserver(new Handler()){
        @Override
        public void onChange(boolean selfChange, Uri uri) {
            super.onChange(selfChange, uri);
            if(uri.compareTo(mUri) == 0 ){
                String weather =mContentResolver.getType(uri);
                setWeather( weather);
            }
        }
        };
        mContentResolver.registerContentObserver(mUri, true, mProviderObserver);
        rnsmc= new ReadNewSmsMissedCall(mContentResolver);
        rnsmc.setChangeTelephonyListener(new ChangeTelephonyListener() {
            public void onChange() {
                setImage();
            }
        });
        rnsmc.registerObserver();
            setImage();
            mHandler = new Handler();
            mRunnable = new Runnable(){
                @Override
                public void run() {
                    if(count == 1){
                        setImage();
                        count = 2;
                    }
                    else if(count == 2){
                        weather = mContentResolver.getType(mUri);
                        setWeather(weather);
                        ount = 1;
                    }
                mHandler.postDelayed(mRunnable, 1000);
                } 
            };
            mRunnable.run();
            mTask = new TimerTask(){
                @Override
                public void run() {
                    new DoTask().execute(url);
                    setWeather(weather);
                }
            };
                mTimer = new Timer();
                mTimer.schedule(mTask, 500, 100000);
                new DoTask().execute(url);
            }
            public class DoTask extends AsyncTask<String, Void, String> {

            @Override
            protected String doInBackground(String... params) {
                for (String urlVal : params) {
                   mPullParser = new PullParser(urlVal);
                    }
            mData = mPullParser.parse();
             ContentValues value = new ContentValues();
             value.put("weather", mData);
             mContentResolver.insert(mUri,value );
             return mData;
               }
             }
            private void setImage(){  //
                int smsCount = rnsmc.getCountNewSms();
                int callCount = rnsmc.getCountMissedCall();
                if( smsCount > 0 && callCount >0){
                    mIv.setImageResource(R.drawable.bump);
                    count = 1;
                }
             }
            private void setWeather(String weather){///

                }
4

1 回答 1

0

你必须使用asynctask如下。

@Override
    protected void onPreExecute() {

//Start your custom animation here OR display progress dialog
}

doInBackground(....)
{

 // code for getting data from webservice
}

onPostExecute(...)
{
// stop your animation OR dialog
}

请参阅此示例。希望能帮助到你。

于 2013-08-02T07:40:43.657 回答