android 定制对话框 Layoutlnflater
来源:互联网 发布:深度linux系统 编辑:程序博客网 时间:2024/04/30 02:32
在main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Button
android:id="@+id/mybut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户登录"/>
</LinearLayout>
在MyDialogDemo.java程序中
package com.tarena.dialog;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
public class MyDialogDemo extends Activity {
private Button mybut = null ; // 定义按钮
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setContentView(R.layout.main); // 调用布局管理器
this.mybut = (Button) super.findViewById(R.id.mybut) ; // 取得按钮
this.mybut.setOnClickListener(new OnClickListenerImpl()) ; // 设置事件类
}
private class OnClickListenerImpl implements OnClickListener {
public void onClick(View view) {
LayoutInflater facotry = LayoutInflater.from(MyDialogDemo.this); //相当于界面的创建工厂
View myview = facotry.inflate(R.layout.login, null); //读取配置文件
Dialog dialog = new AlertDialog.Builder(MyDialogDemo.this)
.setIcon(R.drawable.ic_launcher)
.setTitle("用户登录")
.setPositiveButton("登录", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).setView(myview).create() ; // 设置对话框
dialog.show() ;
}
}
}
在layout文件夹中新建login.xml
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TableRow >
<TextView
android:text="用户名:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
<EditText
android:layout_width="150dp"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow >
<TextView
android:text="密码:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"/>
<EditText
android:password="true"
android:layout_width="150dp"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
- android 定制对话框 Layoutlnflater
- layoutlnflater
- Android定制--------开机对话框的实现
- Android菜鸟在成长-定制对话框和LayoutInflater
- Android界面设计之对话框——定制Toast、AlertDialog
- Android界面设计之对话框——定制Toast、AlertDialog
- 自定制网页对话框
- CFontDialog 对话框定制
- 定制打开文件对话框
- 定制对话框外观
- 定制对话框和LayoutInflater
- 如何定制对话框中的回车键
- 如何定制对话框中的回车键
- 如何定制对话框中的回车键
- 自己定制打开文件对话框
- 如何定制对话框中的回车键
- VC 定制对话框系统菜单
- 如何定制对话框系统菜单
- android 多项对话框
- 2013年下半年全国计算机等级考试二级c语言上机真题(类型一)
- JAVA web编程经验之: 一个请求一个事务
- 修心课(一):心态与生活
- PNG文件结构分析
- android 定制对话框 Layoutlnflater
- eclipse安装Activiti BPMN 2.0 designer
- java内存溢出
- python Queue module
- CSUOJ 1313: ZZY的宠物
- php增删改查,自己写的demo
- 问题3:如何用递归算法判断一个数组是否是递增?
- android 日期对话框
- PNG数据分析(加压和解压)