Android WindowFeature小探究

主Activity,用来提供文字信息和输入效果ID:

package com.zms.windowfeature;

import org.xml.sax.Parser;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.Menu;

import android.view.MenuItem;

import android.view.View;

import android.view.View.OnClickListener;

import android.view.Window;

import android.widget.Button;

import android.widget.EditText;

import android.widget.TextView;

import android.widget.Toast;

public class Main extends Activity {

private Button btnShow;

private TextView tvNowId;

private EditText etNowId;

@Override

protect

ed void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

btnShow = (Button) findViewById(R.id.btnShow);

btnShow.setOnClickListener(new onClickListenerImp());

tvNowId = (TextView) findViewById(R.id.tvNowId);

etNowId = (EditText) findViewById(R.id.etNowId);

}

public class onClickListenerImp implements OnClickListener {

@Override

public void onClick(View v) {

// TODO Auto-generated method stub

String idStr = etNowId.getText().toString();

int id = Integer.parseInt(idStr);

if ((-5 < id && id < 9 && id != 7) || id == 10000 || id == 20000

|| id == 30000) {

// onCreate(null);

Intent intent = new Intent(Main.this, Show.class);

// intent.setClass(Main.this, Show.class);

intent.putExtra("idStr", idStr);

startActivity(intent);

} else if (id == 7) {

Toast.makeText(Main.this, "ID=7:暂未自定义标题栏,无法预览。",

Toast.LENGTH_SHORT).show();

} else {

Toast.makeText(Main.this, "ID=" + id + "非法,请参考提供文字。",

Toast.LENGTH_SHORT).show();

}

}

}

@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;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

// Handle action bar item clicks here. The action bar will

// automatically handle clicks on the Home/Up button, so long

// as you specify a parent activity in AndroidManifest.xml.

int id = item.getItemId();

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

}

Show Activity,接收Main传来的数,用来显示对应的预览效果:

package com.zms.windowfeature;

import android.app.Activity;

import android.content.Intent;

import android.os.Bundle;

import android.view.View;

public class Show extends Activity {

@Override

protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

Intent intent = getIntent();

String idStr = intent.getStringExtra("idStr");

int id = Integer.parseInt(idStr);

requestWindowFeature(id);

setContentView(R.layout.show);

}

public void Back(View v) {

finish();

}

}

文字描述都在主布局文件里面了,也贴上来吧:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

xmlns:tools="http://schemas.android.com/tools"

相关推荐
用户20703861949几秒前
Compose 可点击文本:ClickableText Compose 中的 ClickableSpan
android
常利兵7 分钟前
Kotlin作用域函数全解:run/with/apply/let/also与this/it的魔法对决
android·开发语言·kotlin
幼稚园的山代王20 分钟前
Kotlin-基础语法练习一
android·开发语言·kotlin
闻不多25 分钟前
用llamaindex搭建GAR遇到400
android·运维·服务器
阿华的代码王国35 分钟前
【Android】适配器与外部事件的交互
android·xml·java·前端·后端·交互
跨界混迹车辆网的Android工程师1 小时前
实现Android图片手势缩放功能的完整自定义View方案,结合了多种手势交互功能
android·交互
wyjcxyyy1 小时前
打靶日记-PHPSerialize
android
安卓开发者12 小时前
Android RxJava 组合操作符实战:优雅处理多数据源
android·rxjava
阿华的代码王国13 小时前
【Android】RecyclerView复用CheckBox的异常状态
android·xml·java·前端·后端
一条上岸小咸鱼13 小时前
Kotlin 基本数据类型(三):Booleans、Characters
android·前端·kotlin