package com.hjc;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
public class LayoutInflaterDemo extends Activity implements
OnClickListener {
private Button button;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(this);
}
@Override
public void onClick(View v) {
showCustomDialog();
}
public void showCustomDialog()
{
AlertDialog.Builder builder;
AlertDialog alertDialog;
Context mContext = LayoutInflaterDemo.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("超级无敌。。路飞。。巨人之枪");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.icon);
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
alertDialog = builder.create();
alertDialog.show();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
Aj_04的Android 中LayoutInflater的使用(源码)
共24个文件
class:9个
xml:5个
png:3个
4星 · 超过85%的资源 需积分: 9 8 下载量 190 浏览量
2010-11-24
13:32:56
上传
评论
收藏 36KB ZIP 举报
温馨提示
来自:http://blog.csdn.net/Android_Tutor/archive/2010/04/21/5513869.aspx 测试:Android 中LayoutInflater的使用 注意:Aj_04是用了调用另外一个界面,要注意调用的方法, 还一定还要在AndroidManifest.xml 中加上呢句:<activity android:name="LayoutInflaterDemo"></activity>
资源推荐
资源详情
资源评论
收起资源包目录
Aj_04.zip (24个子文件)
Aj_04
.project 841B
default.properties 364B
Aj_04说明.doc 43KB
bin
com
hjc
R$string.class 394B
R$layout.class 429B
R$drawable.class 367B
Aj_04.class 977B
R.class 454B
R$attr.class 307B
LayoutInflaterDemo.class 2KB
Aj_04$1.class 962B
R$id.class 439B
AndroidManifest.xml 683B
src
com
hjc
LayoutInflaterDemo.java 2KB
Aj_04.java 1KB
res
values
strings.xml 161B
layout
custom_dialog.xml 746B
main_aj.xml 555B
main.xml 532B
drawable-ldpi
icon.png 2KB
drawable-hdpi
icon.png 4KB
drawable-mdpi
icon.png 3KB
.classpath 280B
gen
com
hjc
R.java 990B
assets
共 24 条
- 1
资源评论
- longyu12182013-05-21这个代码,介绍的很容易,也很实用!很喜欢,多多献出这样的资源!
我要做程序达人
- 粉丝: 29
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功