首页 新闻 会员 周边 捐助

求一个关于ImageView控件的invalidateDrawable方法的例子,多谢~

0
悬赏园豆:20 [待解决问题]

看到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);
  }
}

风情123的主页 风情123 | 初学一级 | 园豆:28
提问于:2012-04-01 11:40
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册