package com.example.dialog_1;import android.app.Activity;import android.app.AlertDialog;import android.os.Bundle;import android.os.Handler;public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// ///弹出是否添加城市的 对话框final AlertDialog alert = new AlertDialog.Builder(MainActivity.this).create();alert.setTitle("悟空提示:");alert.setMessage("您是第8位用户");alert.show();new Handler().postDelayed(new Runnable() {@Overridepublic void run() {alert.dismiss();}}, 2000);}////onCreate}
<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"    tools:context="${relativePackage}.${activityClass}" >    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:text="@string/hello_world" /></RelativeLayout>

网上看了一下写的很复杂,我这是简便的方法,

打开就显示2s,后自动消失

更多相关文章

  1. Android(安卓)AlertDialog工具类 实现对话框回调
  2. 简单播放系统提示音 android
  3. Android(安卓)Service实现闹钟
  4. android之AlerDialog
  5. Android实现弹出Toast提示
  6. eclipse运行android时Console最后提示Done!不运行程序
  7. Android对话框实例-注册对话框
  8. Android漂亮的Help提示框
  9. androidの自定义加载对话框ProgressDialog

随机推荐

  1. Android中的shape中的属性大全
  2. Android焦点分发基本流程
  3. Android如何监听开机广播和关机广播
  4. gif in android
  5. Android学习路线总结,绝对干货
  6. ImageView之android:tint=" "属性方法作
  7. Android(安卓)SDCard Mount 流程分析(一)
  8. Android(安卓)应用程序快速启动的秘诀
  9. 【Android(安卓)开发】: Android(安卓)消
  10. android中的SVG图像的各个属性意义