[英]How to set the application to fullscreen from an Intent, Not from the main activity
我的应用程序有4个选项卡,每个选项卡都会创建一个子视图(意图),现在我在每个意图中都有一个用于选项/菜单按钮的处理程序,菜单项为“切换全屏”,这不起作用,因为意图不是父项视图,而包含TabHost的活动是父视图,现在我需要知道如何设置整个应用程序。 进入全屏模式,或如何参考父活动通过它设置全屏模式。
这是我的代码片段
public class MainActivity extends TabActivity {
public void toggleFullScreen(){
// This has the code to set App. to full screen
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent myIntent = new Intent(this, MywebviewActivity.class);
tabHost.addTab(
tabHost.newTabSpec("SomeName")
.setIndicator("Some Title")
.setContent( myIntents ));
现在,我需要从“ MywebviewActivity”而不是从MainActivity设置全屏模式
检查这个
将此添加到您的webview活动中
Intent i=getIntent();
if(i!=null)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
如下修改MainActivity
代码
Intent myIntent = new Intent(this, MywebviewActivity.class);
intent.putExtra("isFullScreen", true);
现在在MywebviewActivity
onCreate()
方法中编写代码,如下所示
把“ setContentView(R.layout.main);” 此代码下面的方法如下:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent=getIntent();
boolean isfullScreen = intent.getBooleanExtra("isFullScreen", false);
if(isfullScreen )
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
setContentView(R.layout.main);
}
不行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.