Android 自定义标题栏
来源:互联网 发布:徐文长手对知俯 编辑:程序博客网 时间:2024/05/17 09:25
转自:http://lovezhou.iteye.com/blog/849953
核心代码:
//设置标志为自定义标题栏
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.custom_title);
//设置自定义标题栏,该句必须放在setContentView之后
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
效果图:
- package com.zhou.activity;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.Window;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class CustomTitleActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- //关键代码
- //设置自定义标题栏标志
- requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
- //显示页面
- setContentView(R.layout.custom_title);
- //设置自定义标题栏,改句必须放在setContentView之后
- getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_1);
- final TextView leftText = (TextView) findViewById(R.id.left_text);
- final TextView rightText = (TextView) findViewById(R.id.right_text);
- final EditText leftTextEdit = (EditText) findViewById(R.id.left_text_edit);
- final EditText rightTextEdit = (EditText) findViewById(R.id.right_text_edit);
- Button leftButton = (Button) findViewById(R.id.left_text_button);
- Button rightButton = (Button) findViewById(R.id.right_text_button);
- //按钮事件处理
- leftButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- leftText.setText(leftTextEdit.getText());
- }
- });
- rightButton.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- rightText.setText(rightTextEdit.getText());
- }
- });
- }
- }
- android自定义标题栏progressBar
- Android自定义标题栏
- 自定义android标题栏
- android实现自定义标题栏
- Android自定义标题栏
- Android 自定义标题栏
- Android 自定义标题栏
- Android自定义标题栏
- Android自定义标题栏
- android之自定义标题栏
- Android自定义标题栏
- Android 自定义标题栏运用
- Android 自定义标题栏
- android ListView+自定义标题栏
- Android 自定义标题栏
- Android:自定义标题栏
- Android Actionbar自定义标题栏
- 自定义Android标题栏TitleBar
- Fixcel电子表单——前端动作脚本(二):页面加载
- iPad 2安全隐患:用智能套破解密码锁屏
- HttpServletResponse
- Action里面获得request response session
- VB.NET之旅(五)—类的继承
- Android 自定义标题栏
- js常用正则表达式实例
- Linux软件之——小企鹅输入法fcitx
- dsfsafa
- VB.NET之旅(六)—重载与隐藏
- QGIS1.7.1版本编译
- 编辑距离
- 平衡二叉树的完整实现
- Web应用程序的会话(Cookie)介绍