看到API文档:
public void invalidateDrawable (Drawable dr)
Since: API Level 1 Invalidates the specified Drawable.
Parameters
dr the drawable to invalidate
看到这个API文档,我的理解是它试图刷新图片的;但是我尝试写改个例子但是没效果的;
请大家指正我下面的例子哪里错了啊?
package com.android.Invalidate;
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
public class InvalidateActivity extends Activity {
/** Called when the activity is first created. */
static int times = 1;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView imageView = (ImageView)findViewById(R.id.ImageView);
Drawable drawable = getResources().getDrawable(R.drawable.ic_launcher);
imageView.setImageDrawable(drawable);
imageView.invalidateDrawable(drawable);
imageView.setImageDrawable(drawable);
}
}