我试图禁用状态栏和主页和历史按钮在React Native使用android本机代码。react native为back btn提供了功能。
主活动.java
package com.kiosk;
import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
import com.facebook.react.ReactRootView;
import com.swmansion.gesturehandler.react.RNGestureHandlerEnabledRootView;
import org.devio.rn.splashscreen.SplashScreen;
import android.os.Bundle;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
SplashScreen.show(this);
FullScreencall();
super.onCreate(savedInstanceState);
}
public void FullScreencall() {
if(Build.VERSION.SDK_INT < 19){
View v = this.getWindow().getDecorView();
v.setSystemUiVisibility(View.GONE);
} else {
//for higher api versions.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
}
@Override
protected String getMainComponentName() {
return "AwesomeProject";
}
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new ReactActivityDelegate(this, getMainComponentName()) {
@Override
protected ReactRootView createRootView() {
return new RNGestureHandlerEnabledRootView(MainActivity.this);
}
};
}
}
获取时出错:
error: cannot find symbol
v.setSystemUiVisibility(View.GONE);
^
symbol: variable View
location: class MainActivity
error: cannot find symbol
View decorView = getWindow().getDecorView();
^
symbol: class View
location: class MainActivity
error: cannot find symbol
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
^
symbol: variable View
location: class MainActivity
error: cannot find symbol
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
^
symbol: variable View
location: class MainActivity
你有没有在react native或java中这样做过请帮我我卡住了,一些代码片段会很有帮助的
1条答案
按热度按时间jdg4fx2g1#
你忘了导入视图类。将此行添加到mainactivity.java的开头: