andriod 4.1 隐藏虚拟按键和导航栏

package com.example.xw1;

import android.os.Bundle;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

@SuppressLint("NewApi")
public class MainActivity extends Activity implements OnClickListener {
	View main;
	private TextView textV;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		main = getLayoutInflater().from(this).inflate(R.layout.activity_main,
				null);
		main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
		main.setOnClickListener(this); 
		setContentView(main);
		textV = (TextView)this.findViewById(R.id.textview);
		textV.setText("HELLO WORLD!");
		Button b1 = (Button)this.findViewById(R.id.b1);
		Button b2 = (Button)this.findViewById(R.id.b2);
		Button b3 = (Button)this.findViewById(R.id.b3);
		Button b4 = (Button)this.findViewById(R.id.b4);
		Button b5 = (Button)this.findViewById(R.id.b5);
		Button b6 = (Button)this.findViewById(R.id.b6);
		Button b7 = (Button)this.findViewById(R.id.b7);
		Button b8 = (Button)this.findViewById(R.id.b8);
		Button b9 = (Button)this.findViewById(R.id.b9);
		b1.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
				textV.setText("SYSTEM_UI_FLAG_FULLSCREEN");
			}
		});
		b2.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
				textV.setText("SYSTEM_UI_FLAG_HIDE_NAVIGATION");
			}
		});
		b3.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
				textV.setText("SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN");
			}
		});
		b4.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
				textV.setText("SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION");
			}
		});
		b5.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
				textV.setText("SYSTEM_UI_FLAG_LAYOUT_STABLE");
			}
		});
		b6.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
				textV.setText("SYSTEM_UI_FLAG_LOW_PROFILE");
			}
		});
		b7.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
				textV.setText("SYSTEM_UI_FLAG_VISIBLE");
			}
		});
		b8.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				int newVis = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
				main.setSystemUiVisibility(newVis);
				textV.setText("31");
			}
		});
		b9.setOnClickListener(new Button.OnClickListener(){
			@Override
			public void onClick(View arg0) {
				int newVis = View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
				main.setSystemUiVisibility(newVis);
				textV.setText("32");
			}
		});
		
		
		
	}
	
	@Override
	public void onClick(View v) {
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
 
 

几个参数一个个试试就知道了!




你可能感兴趣的:(andriod 4.1 隐藏虚拟按键和导航栏)