LayoutInflater的应用

MyTestActivity.java

package com.android.demo;import android.app.Activity;import android.app.AlertDialog;import android.content.Context;import android.content.DialogInterface;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import android.widget.TextView;public class MyTestActivity extends Activity { @Overrideprotected void onCreate(Bundle savedInstanceState) {// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.main);        Context mContext = MyTestActivity.this;                              //下面俩种方法都可以               //LayoutInflater inflater = getLayoutInflater();               LayoutInflater inflater = (LayoutInflater)                mContext.getSystemService(LAYOUT_INFLATER_SERVICE);               View layout = inflater.inflate(R.layout.custom_dialog,null);               TextView text = (TextView) layout.findViewById(R.id.text);               text.setText(" 感谢您选择使用金软office办公软件,请注册并激活软件,即可获得软件正式版的使用权。");           new AlertDialog.Builder(MyTestActivity.this).setIcon(android.R.drawable.ic_menu_info_details).setTitle("金软Office[试用版]").setView(layout).setPositiveButton("确定", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO Auto-generated method stub}}).show();}}
XML文件:custom_dialog.xml
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:orientation="vertical"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    ><TextView      android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:text="试用期剩余14天"    android:gravity="center"    /><TextView      android:id="@+id/text"    android:layout_width="fill_parent"     android:layout_height="wrap_content"     /><EditText     android:id="@+id/edit"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:hint="请输入email......"    /></LinearLayout>

EditText中的提示:
android:hint="请输入email......"
效果图



更多相关文章

  1. android 弹出软盘
  2. android软件开发:横竖屏
  3. android页面管理器。可以实现完整退出android软件
  4. android中软件参数保存
  5. android软件工程师/android中间件开发
  6. Android使用SAX解析XML(1)
  7. 新的Android恶意软件出现!可能窃取你的银行密码
  8. Android软件开发需要学什么
  9. MIUI 惊艳锁屏样式5款[Android] | 小众软件 > Android

随机推荐

  1. Android(安卓)Studio 视图解析
  2. Android子线程真的不能更新UI么
  3. android发送/接收json数据
  4. 归纳整理一些工作学习中发现的不错的网站
  5. Android(安卓)Application Task Activiti
  6. android环境配置和工程目录介绍
  7. 腾讯轻听模仿流水账(1):16.11.25
  8. arcgis for android 学习 - (7) 在真机上
  9. android 实用项目备份【GitHub】(三)
  10. Android缩放drawable