【发布时间】:2015-03-31 11:11:37
【问题描述】:
我在 onConfigurationChanged 侧声明了一个 int jj 函数,现在我想在同一类的 onConfigurationChangedanywhare 之外访问它。
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Checks the orientation of the screen
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this, "landscape", Toast.LENGTH_SHORT).show();
final int jj=4;
} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(this, "portrait", Toast.LENGTH_SHORT).show();
final int jj=2;
}
}
我想像这样在同一个类中访问这个变量:
public class MainActivity extends Activity {
public static int aa=jj;
}
【问题讨论】:
标签: java android integer static-variables