我想在更改服务的图像视图时进行动画制作

时间:2013-08-02 07:28:05

标签: android animation service imageview tween

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){///

                }

1 个答案:

答案 0 :(得分: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
}

Example。希望它有所帮助。