我有一个带有private static final字段的类,不幸的是,我需要在运行时更改.
使用反射我得到这个错误: java.lang.IllegalAccessException: Can not set static final boolean field
有没有办法改变价值?
Field hack = WarpTransform2D.class.getDeclaredField("USE_HACK");
hack.setAccessible(true);
hack.set(null, true);
Run Code Online (Sandbox Code Playgroud) 我在点击TabActivity当前选中的标签时尝试获取Click事件.
我尝试下面的代码,但当我点击一个选项卡时,其他选项卡无法正常工作/单击.
setupTab(new TextView(this), "Map");
setupTab(new TextView(this), "Attacks");
setupTab(new TextView(this), "Profile");
setupTab(new TextView(this), "Headquater");
int numberOfTabs = tabHost.getTabWidget().getChildCount();
for(int t=0; t<numberOfTabs; t++){
getTabWidget().getChildAt(t).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(tabHost.getCurrentTab() == 0){
Toast.makeText(TabContext, ""+"i m in on clickkkkk" ,1500).show();
getTabHost().setCurrentTab(0);
}
if(tabHost.getCurrentTab() == 1){
Toast.makeText(TabContext, ""+"i m in on clickkkkk....$#@$#$" ,1500).show();
getTabHost().setCurrentTab(1);
}
}
});
}
Run Code Online (Sandbox Code Playgroud)