如何解决Android程序“从不本地读取”中的警告? [英] how to solve warning in android program "never read locally"
本文介绍了如何解决Android程序“从不本地读取”中的警告?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么我会收到警告:
The field testscreen.ScaleAnimToShow.mVanishAfter is never read locally testscreen.java /testscreen/src/com/testscreen line 186 Java Problem
来自以下代码?
public class ScaleAnimToShow extends ScaleAnimation{
private View mView;
private LayoutParams mLayoutParams;
private int mMarginBottomFromY, mMarginBottomToY;
private boolean mVanishAfter = false;
public ScaleAnimToShow(float toX, float fromX, float toY, float fromY, int duration, View view,boolean vanishAfter){
super(fromX, toX, fromY, toY);
openLayout = view;
setDuration(duration);
mView = view;
mVanishAfter = vanishAfter;
mLayoutParams = (LayoutParams) view.getLayoutParams();
mView.setVisibility(View.VISIBLE);
int height = mView.getHeight();
//mMarginBottomFromY = (int) (height * fromY) + mLayoutParams.bottomMargin + height;
//mMarginBottomToY = (int) (0 - ((height * toY) + mLayoutParams.bottomMargin)) + height;
mMarginBottomFromY = 0;
mMarginBottomToY = height;
Log.v("CZ",".................height..." + height + " , mMarginBottomFromY...." + mMarginBottomFromY + " , mMarginBottomToY.." +mMarginBottomToY);
}
推荐答案
这是因为您拥有该字段会在内存中占用一些空间,但是永远不会在程序中的任何地方读取该内容。
That's because you have the field that occupies some space in memory but which is never read anywhere in your program.
您可以解决此警告:
- 删除此字段。如果您不使用它,请不要将其保留在代码中。
或 - 添加
@SuppressWarnings( unused)
批注。当通过注释使用此字段或出于其他原因要将其保留在代码中时,这可能很有用。
- Remove this field. If you don't use it, don't keep it in your code.
or - Add
@SuppressWarnings("unused")
annotation. This may be useful when this field is used via annotation, or you want to keep it in code for other reasons.
@SuppressWarnings("unused")
private boolean mVanishAfter = false;
这篇关于如何解决Android程序“从不本地读取”中的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文