自己定义AlertDialog对话框布局
自己定义对话框中的信息body布局
LayoutInflater inflater =getLayoutInflater();
View layout = inflater.inflate(R.layout.alert_dialog_content, null);
AlertDialog musicDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT).create();
musicDialog.setView(layout);
TextView textView = (TextView)layout.findViewById(R.id.message);
textView.setText(mDialogDesc);
musicDialog.setTitle(R.string.delete_item);
musicDialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(R.string.delete_confirm_button_text), mButtonClicked);
musicDialog.setButton(DialogInterface.BUTTON_NEUTRAL, getResources().getString(R.string.cancel), mButtonClicked);
musicDialog.setCanceledOnTouchOutside(true);
musicDialog.setCancelable(true);
musicDialog.setOnKeyListener(mSearchKeyListener);
musicDialog.setIcon(android.R.drawable.ic_dialog_alert);
return musicDialog;
布局文件:
<?
xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/parentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="8dip"
android:layout_marginEnd="8dip"
android:orientation="vertical">
<LinearLayout android:id="@+id/contentPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="12dip"
android:paddingBottom="12dip"
android:orientation="vertical">
<ScrollView android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView android:id="@+id/message"
style="?android:attr/textAppearanceMedium"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dip"
android:paddingEnd="16dip"
android:paddingTop="8dip"
android:paddingBottom="8dip"/>
</ScrollView>
</LinearLayout>
</LinearLayout>
自己定义AlertDialog对话框布局的更多相关文章
- android 开发 实现一个自定义布局的AlertDialog对话框
对话框有很多实现方法,最常见的是在一个点击事件中代码直接写出对话框.如下: package com.example.lenovo.mydemo2; import android.content.Dia ...
- 在有EditText控件的AlertDialog对话框中自动弹出输入法
我们先回顾一下创建AlertDialog的一般步骤. 一 inflate AlertDialog的布局文件 例如,其中dlg就是我们的布局文件. View layout = LayoutIn ...
- Android应用开发学习之AlertDialog对话框
作者:刘昊昱 博客:http://blog.csdn.net/liuhaoyutz 本文中我们通过一个例子来看AlertDialog对话框的实现,其运行效果如下: 主布局文件main.xml内容如下: ...
- Android学习:AlertDialog对话框
AlertDialog可以生成各种内容的对话框,它生成的对话框包含4个区域:图标区,标题区,内容区,按钮区 <?xml version="1.0" encoding=&quo ...
- 安卓 自定义AlertDialog对话框(加载提示框)
AlertDialog有以下六种使用方法: 一.简单的AlertDialog(只显示一段简单的信息) 二.带按钮的AlertDialog(显示提示信息,让用户操作) 三.类似ListView的Aler ...
- [android] 手机卫士自定义对话框布局
手机防盗页面部分 点击手机防盗,进行判断,如果没有设置密码,显示一个设置密码的对话框,如果已经设置密码了,弹出输入密码对话框 密码保存在SharedPreferences中,数据取出进行判断 自定义一 ...
- 【转】Android AlertDialog自定义布局
原文网址:https://blog.csdn.net/u010694658/article/details/53022294 由于开发中经常使用弹框,然而系统自带的弹框太局限,也不太美观,经常不能满足 ...
- android入门 — AlertDialog对话框
常见的对话框主要分为消息提示对话框.确认对话框.列表对话框.单选对话框.多选对话框和自定义对话框. 对话框可以阻碍当前的UI线程,常用于退出确认等方面. 在这里主要的步骤可以总结为: 1.创建Aler ...
- AlertDialog 对话框 5种
MainActivity.class public class MainActivity extends AppCompatActivity implements View.OnClickListen ...
随机推荐
- Netty框架入门
一.概述 Netty是由JBOSS提供的一个java开源框架. Netty提供异步的.事件驱动的网络应用程序框架和工具,用以快速开发高性能.高可靠性的网络服务器和客户端程序. 二. ...
- Tutorial 2: Requests and Responses
转载自:http://www.django-rest-framework.org/tutorial/2-requests-and-responses/ Tutorial 2: Requests and ...
- MySQL 操作总结
1. 数据库级别操作 1.1 创建数据库 CREATE DATABASE db1 default charset utf8 collate utf8_general_ci; 1.2 删除数据库 DRO ...
- poj 1041(字典序输出欧拉回路)
John's trip Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8641 Accepted: 2893 Spe ...
- Linux 基础——权限管理命令chown、chgrp
一.chown命令与chgrp命令的作用 有时你需要改变文件或目录的属主,比如有人离职或开发人员创建了一个在测试或生产环境中需要归属在系统账户下的应用.Linux提供了两个命令来实现这个功能:chow ...
- 服务器fsockopen函数和pfsockopen函数开启及作用
摘要: fsockopen()函数的作用是可以用来打开一个socket连接,另一个函数pfsockopen()也有相似的功能,只不过后者是一个“持续”(persistent)的fsockopen()函 ...
- for循环练习题(共六道题)
第一题: 假设一个简单的ATM机的取款过程是这样的:首先提示用户输入密码(password),最多只能输入三次,超过3次则提示用户“密码错误,请取卡”结束交易.如果用户密码正确,再提示用户输入取款金额 ...
- bzoj 1106
思路:很容易就能想到统计没两对点之间的未匹配点的个数. 在想怎么用数据结构维护这个东西, 没有想到用树状数组能很巧妙地维护出来, 就写了个莫队... 莫队:暴力维护就好了. #include<b ...
- 在 Windows 上进行 Laravel Homestead 安装、配置及测试
软件环境:在 Windows 7 64位 上基于 VirtualBox 5.2.12 + Vagrant 2.1.1 使用 Laravel Homestead. 1.准备 先下载VirtualBox- ...
- poj2253 Frogger(Floyd)
题目链接 http://poj.org/problem?id=2253 题意 给出青蛙A,B和若干石头的坐标,现在青蛙A要跳到青蛙B所在的石头上,求出所有路径中最远那一跳的最小值. 思路 Floyd算 ...