0
我有两个类,A类叫做应用和B类称为选项 我想A级摆脱B级的资源,但我发现了错误来自不同类的Android getResources
我的错误得到
Cannot make a static reference to the non-static method getResources() from the type ContextWrapper
上A类
public static void applyBitmap(int resourceID) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inScaled = true;
opt.inPurgeable = true;
opt.inInputShareable = true;
Bitmap brightBitmap = BitmapFactory.decodeResource(getResources(), resourceID, opt);
brightBitmap = Bitmap.createScaledBitmap(brightBitmap, 100, 100, false);
MyBitmap = brightBitmap;
}
和示例的资源按钮的功能在B类
// the 34th button
Button tf = (Button) findViewById(R.id.tFour);
tf.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Apply.applyBitmap(R.drawable.tFour);
}
});
note *:之前当功能在B类中的功能很好,但知道我认为我需要静态资源,但是如何?我不知道
我试图Option.getResources()
但没有奏效,它给出了一个错误
如果你删除从A类的 “静态”?你需要静态吗?其实它对java的基本理解。我虚心地建议你重新阅读Java基础知识。 – 2012-08-16 02:21:16
Yoi声明:public static void applyBitmap(int resourceID) – 2012-08-16 02:25:35