android 自定义View 对话框
package com.example.dialog5;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.View;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// 取得自定义View
LayoutInflater layoutInflator = LayoutInflater.from(this);
View myLoginView = layoutInflator.inflate(R.layout.login, null);
Dialog myDialog = new AlertDialog.Builder(MainActivity.this)
.setTitle("登录")
.setIcon(R.drawable.ic_launcher)
.setView(myLoginView)
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
};
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
}
})
.create();
myDialog.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;
}
}
最新文章
- node.js学习(二)--Node.js控制台(REPL)&;&;Node.js的基础和语法
- 第10章 Shell编程(1)_正则表达式
- [Android]listview recycleview的复用问题
- 移动平台自动化测试从零开始-MonkeyRunner工具使用 (第二节)
- 【JS复习笔记】04 数组
- JavaScript 实现鼠标拖动元素
- c#中分布方法和分部类
- Python基础学习笔记(一)入门
- hibernate对象关系实现(一)一对多
- C#如何使用HttpWebRequest、HttpWebResponse模拟浏览器抓取网页内容
- usb host和usb device
- HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)
- Postgresql查询最近12个月、最近30天数据
- 物联网框架ServerSuperIO
- win(64位)环境下oracle11g的安装方法
- Immuable详解以及在React中的实战
- iOS开发swift语法0基础篇—————(swift技术交流群:361513739)
- Efficiency optimizing
- 转载:负载均衡器技术Nginx和F5的优缺点对比
- bootstrap做的导航
热门文章
- 考虑下面两个JSP文件代码片断: test1.jsp:
- C++继承具体解释之二——派生类成员函数具体解释(函数隐藏、构造函数与兼容覆盖规则)
- maven 完整的settings.xml
- hdu 2918(IDA*)
- DBA面试题及解答
- 分页技巧__在项目中使用QueryHelper辅助对象实现分页效果
- excel如何将一个工作薄中的工作表生成独立的工作薄
- MemSQL start[c]up Round 1.E
- python线程池ThreadPoolExecutor用法
- JS内存泄漏排查方法-Chrome Profiles