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

}

最新文章

  1. node.js学习(二)--Node.js控制台(REPL)&&Node.js的基础和语法
  2. 第10章 Shell编程(1)_正则表达式
  3. [Android]listview recycleview的复用问题
  4. 移动平台自动化测试从零开始-MonkeyRunner工具使用 (第二节)
  5. 【JS复习笔记】04 数组
  6. JavaScript 实现鼠标拖动元素
  7. c#中分布方法和分部类
  8. Python基础学习笔记(一)入门
  9. hibernate对象关系实现(一)一对多
  10. C#如何使用HttpWebRequest、HttpWebResponse模拟浏览器抓取网页内容
  11. usb host和usb device
  12. HDOJ 1397 Goldbach's Conjecture(快速筛选素数法)
  13. Postgresql查询最近12个月、最近30天数据
  14. 物联网框架ServerSuperIO
  15. win(64位)环境下oracle11g的安装方法
  16. Immuable详解以及在React中的实战
  17. iOS开发swift语法0基础篇—————(swift技术交流群:361513739)
  18. Efficiency optimizing
  19. 转载:负载均衡器技术Nginx和F5的优缺点对比
  20. bootstrap做的导航

热门文章

  1. 考虑下面两个JSP文件代码片断: test1.jsp:
  2. C++继承具体解释之二——派生类成员函数具体解释(函数隐藏、构造函数与兼容覆盖规则)
  3. maven 完整的settings.xml
  4. hdu 2918(IDA*)
  5. DBA面试题及解答
  6. 分页技巧__在项目中使用QueryHelper辅助对象实现分页效果
  7. excel如何将一个工作薄中的工作表生成独立的工作薄
  8. MemSQL start[c]up Round 1.E
  9. python线程池ThreadPoolExecutor用法
  10. JS内存泄漏排查方法-Chrome Profiles