[英]How to set the application to fullscreen from an Intent, Not from the main activity
My Application Has 4 Tabs, Each tab creates a subview ( intent ) now I have a handler for options/menu button within each intent , of the menu items is "Toggle Fullscreen" this doesn't work as the intent isn't the parent view while the activity containing the TabHost is the parent View, Now I need to know how do I Set the whole app. 我的应用程序有4个选项卡,每个选项卡都会创建一个子视图(意图),现在我在每个意图中都有一个用于选项/菜单按钮的处理程序,菜单项为“切换全屏”,这不起作用,因为意图不是父项视图,而包含TabHost的活动是父视图,现在我需要知道如何设置整个应用程序。 to FullScreen mode or how to Refer to the Parent Activity to Set the full screen mode through it.
进入全屏模式,或如何参考父活动通过它设置全屏模式。
Here's a snippet of my code 这是我的代码片段
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 ));
Now I need to set fullscreen mode from "MywebviewActivity" not from my MainActivity 现在,我需要从“ MywebviewActivity”而不是从MainActivity设置全屏模式
check this 检查这个
add this in your webview activity 将此添加到您的webview活动中
Intent i=getIntent();
if(i!=null)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
modify code in your MainActivity
as following 如下修改
MainActivity
代码
Intent myIntent = new Intent(this, MywebviewActivity.class);
intent.putExtra("isFullScreen", true);
now in onCreate()
method of MywebviewActivity
write code as following 现在在
MywebviewActivity
onCreate()
方法中编写代码,如下所示
put "setContentView(R.layout.main);" 把“ setContentView(R.layout.main);” method below of this code as following :
此代码下面的方法如下:
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);
}
not it will work 不行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.