如何设置从意向到全屏,而不是从主要活动申请 [英] How to set the application to fullscreen from an Intent, Not from the main activity
问题描述
我的应用程序有4个标签,每个标签创建一个子视图(意向),现在我有选项/菜单键处理程序的每个意图中,菜单项是切换全屏,这并不为意ISN工作 t是父视图,而含有TabHost活动是父视图,现在我需要知道如何设置整个应用程序。到全屏模式,或如何引用父活动通过它来设置全屏模式。
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. to FullScreen mode or how to Refer to the Parent Activity to Set the full screen mode through it.
下面是我的code的片段
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 ));
现在我需要从MywebviewActivity设置全屏模式不是从我MainActivity
Now I need to set fullscreen mode from "MywebviewActivity" not from my MainActivity
推荐答案
修改code在 MainActivity
如下
Intent myIntent = new Intent(this, MywebviewActivity.class);
intent.putExtra("isFullScreen", true);
现在的onCreate()
MywebviewActivity
写code的方法如下
now in onCreate()
method of MywebviewActivity
write code as following
投入的setContentView(R.layout.main);低于这个code的方法如下:
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);
}
不是会正常工作
这篇关于如何设置从意向到全屏,而不是从主要活动申请的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!