自己定义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 ...
随机推荐
- Tutorial 2: Requests and Responses
转载自:http://www.django-rest-framework.org/tutorial/2-requests-and-responses/ Tutorial 2: Requests and ...
- acm专题---最小生成树
kruscal(eloge): 题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1102 Problem Description There are N ...
- requests 介绍
一. requests 参数 - method: 提交方式 - url: 提交地址 - params: 在URL中传递的参数,GET - data: 在请求体里传递的数据 - json 在请求体里传 ...
- golang基础之一
一.第一个go程序 package main import ( "fmt" ) func main(){ fmt.Println("hello world") ...
- jquery datatable的详细用法
1,首先需要引用下面两个文件 <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css ...
- C#窗体内嵌外部程序(cmd.exe)的显示【转载】
[DllImport("User32.dll ", EntryPoint = "SetParent")] private static extern IntPt ...
- python动态获取对象的属性和方法 (转)
转自未知,纯个人笔记使用 首先通过一个例子来看一下本文中可能用到的对象和相关概念. #coding:utf-8 import sys def foo():pass class Cat(object): ...
- The dd command of linux
The dd command stands for "data duplicator" and used for copying and converting data. It i ...
- bash shell 关系
linux的bash和shell关系 shell通俗理解:把用户输入的命令翻译给操作系统. shell 是一个交互性命令解释器.shell独立于操作系统,这种设计让用户可以灵活选择适合自己的shell ...
- Unity 2D游戏开发教程之使用脚本实现游戏逻辑
Unity 2D游戏开发教程之使用脚本实现游戏逻辑 使用脚本实现游戏逻辑 通过上一节的操作,我们不仅创建了精灵的动画,还设置了动画的过渡条件,最终使得精灵得以按照我们的意愿,进入我们所指定的动画状态. ...