- 浏览: 26243 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (26)
- java排序 (1)
- android进程 (1)
- android音乐播放 (1)
- android 相机 (1)
- android phonegap (0)
- android surfaceView (1)
- android dialog (2)
- android 下拉列表 (1)
- android TextView (1)
- android 自定义列表 (1)
- android json (2)
- android readXml (1)
- android 抽屉菜单 (1)
- android sensor传感器 (1)
- android aidl通信 (2)
- android sqlite数据库 (1)
- android wifi打开 (1)
- android HttpClient (1)
- android 滚动显示图片 (0)
- android 多线程 (1)
- android 百度地图 (1)
- android xListView分页 (1)
- android BlueTooth蓝牙 (1)
- Activity的四种加载模式 (1)
- android intent (1)
最新评论
MainActivity.java
activity_main.xml
custom.xml
package com.simpleDialog; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.os.Bundle; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup.LayoutParams; import android.widget.Button; public class MainActivity extends Activity implements OnClickListener { private Button btn_simple, btn_custom, btn_progress, btn_single, btn_multi; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); btn_simple = (Button) findViewById(R.id.btn_simple); btn_custom = (Button) findViewById(R.id.btn_custom); btn_progress = (Button) findViewById(R.id.btn_progress); btn_single = (Button) findViewById(R.id.btn_single); btn_multi = (Button) findViewById(R.id.btn_multi); btn_simple.setOnClickListener(this); btn_custom.setOnClickListener(this); btn_progress.setOnClickListener(this); btn_single.setOnClickListener(this); btn_multi.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.btn_simple: showDialog(R.id.btn_simple); break; case R.id.btn_custom: showDialog(R.id.btn_custom); break; case R.id.btn_progress: showDialog(R.id.btn_progress); break; case R.id.btn_single: showDialog(R.id.btn_single); break; case R.id.btn_multi: showDialog(R.id.btn_multi); break; } } @Override public Dialog onCreateDialog(int id) { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); switch (id) { case R.id.btn_simple: { builder.setTitle("my dialog btn_simple"); builder.setNegativeButton("取消", null); builder.setPositiveButton("确定", null); builder.setNeutralButton("中立", null); break; } case R.id.btn_custom: { builder.setTitle("my dialog btn_custom"); View view =LayoutInflater.from(this).inflate(R.layout.custom, null); builder.setView(view); builder.setPositiveButton("确定", null); builder.setNegativeButton("取消", null); builder.setNeutralButton("中立", null); break; } case R.id.btn_progress: { ProgressDialog progressDialog=new ProgressDialog(this); progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progressDialog.setMessage("正在下载"); return progressDialog; } case R.id.btn_single: { builder.setTitle("my dialog btn_single"); builder.setSingleChoiceItems(new String[]{"aaa","bbb","ccc","ddd","eee"}, 0, null); builder.setPositiveButton("确定", null); builder.setNegativeButton("取消", null); builder.setNeutralButton("中立", null); break; } case R.id.btn_multi: { builder.setTitle("my dialog btn_multi"); builder.setMultiChoiceItems(new String[]{"aaa","bbb","ccc","ddd","eee"},null, null); builder.setPositiveButton("确定", null); builder.setNegativeButton("取消", null); builder.setNeutralButton("中立", null); break; } } return builder.create(); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_main, menu); return true; } }
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <Button android:id="@+id/btn_simple" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:text="简单的Dialog" /> <Button android:id="@+id/btn_custom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_below="@id/btn_simple" android:text="自定义Dialog" /> <Button android:id="@+id/btn_progress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_below="@id/btn_custom" android:text="进度条Dialog" /> <Button android:id="@+id/btn_single" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_below="@id/btn_progress" android:text="单选Dialog" /> <Button android:id="@+id/btn_multi" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_below="@id/btn_single" android:text="复选Dialog" /> </RelativeLayout>
custom.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ScrollView android:layout_width="match_parent" android:layout_height="300dp" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <ImageView android:id="@+id/img1" android:layout_width="match_parent" android:layout_height="wrap_content" android:src="@drawable/ic_launcher" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="请在下面输入内容" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:text="请在这里输入内容" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="以下是单选框" /> <RadioGroup android:layout_width="match_parent" android:layout_height="wrap_content" > <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:text="aaa" /> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:text="bbb" /> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ccc" /> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ddd" /> <RadioButton android:layout_width="match_parent" android:layout_height="wrap_content" android:text="eee" /> </RadioGroup> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="以下是复选框" /> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:text="aaa" /> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:text="bbb" /> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ccc" /> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:text="ddd" /> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:text="eee" /> <CheckBox android:layout_width="match_parent" android:layout_height="wrap_content" android:text="fff" /> </LinearLayout> </ScrollView> </LinearLayout>
- com.simpleDialog.rar (686.8 KB)
- 下载次数: 0
相关推荐
本文主要介绍Android Dialog,这里详细介绍Android Dialog的基本使用方法,并提供了示例代码和实现效果图,有需要的小伙伴可以参考下
Android技术知识点:如何改造过时的FlycoTabLayout组件
Android技术知识点:如何改造过时的DialogUI组件
startActivityForResult过时.md
Android技术知识点:如何改造过时的LikeButton组件
AsyncTask的用法
在用android studio(v3.6.1)运行项目时,出现以下提示(warning)信息: Deprecated Gradle features were used in this build, making it ...在网上搜索一通后,主要有几种方法: 使用项目下自带的gradle.bat(windows平
【检测seo优化设置】检测SEO优化技巧是否过时的几个方法.docx【检测seo优化设置】检测SEO优化技巧是否过时的几个方法.docx【检测seo优化设置】检测SEO优化技巧是否过时的几个方法.docx【检测seo优化设置】检测SEO...
显示本机IP地址方法,会有过时方法,这个是新方法
2022年 UnityWebRequest.isNetworkError”已过时,弃用,解决方法
#非常过时,请永远不要使用它看看 、 和其他用于并发数据处理的库 ##为什么要使用它? 从 Android Api >= AsyncTasks 是串行执行的,这意味着你不能在不调用 task.executeOnExecutor(...) 的情况下同时运行 2 个或...
android-webview Android webview 到指定 URL 的基本来源。 这在很大程度上已经过时了。 使用风险自负!
如题,网上很多关于发送中文短信的方法,但是真要用的时候,发现能找到的方法都过时了;基本上那些方法都是说要重新构造PDU; 但是在andriod1.6之后,SubmitPdu 类被隐藏掉了,方法直接被废掉了; 不过还是有...
Android带过期时间的可加密二级缓存(LruCache DiskLruCache)
Dialog在android中是非常常用的,对于网络提示很常用,但是系统自带的效果不好,我自定义了一个希望和大家交流
主要介绍了Android onClick方法与setOnClickListener方法对比的相关资料,这两个方法都是点击事件处理函数的方法,它们之间到底有什么区别呢,下面就给大家说下,需要的朋友可以参考下
Android中经常会遇到把View转换为Bitmap的情形,比如,对整个屏幕视图进行截屏并生成图片;Coverflow中需要把一页一页的view转换为Bitmap、以便实现复杂的图形效果(阴影、倒影效果等);再比如一些动态的实时View为...
主要介绍了使用Spring boot标记一个方法过时,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
NULL 博文链接:https://shenbai.iteye.com/blog/1821466
下面小编就为大家分享一篇Android获取栈顶的应用包名方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧