Android studio 使用dialog提示信息
package com.example.androidtest2;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private EditText editText;
private ImageView imageView;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button button = (Button) findViewById(R.id.Button);
editText =(EditText) findViewById(R.id.edit_text);
imageView = (ImageView) findViewById(R.id.image_view);
progressBar = (ProgressBar) findViewById(R.id.progress_bar);
button.setOnClickListener(this);
}
public void onClick(View v){
switch (v.getId()){
case R.id.Button:
int progress = progressBar.getProgress();
progress = progress+10;
AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
dialog.setTitle("有个超级重要的信息");
dialog.setMessage("大家手里还有硬币吗?");
dialog.setCancelable(false);
dialog.setPositiveButton("都给你", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
}
});
dialog.show();
//这里写逻辑
break;
default:
break;
}
}
}
Android studio 使用dialog提示信息的更多相关文章
- 好看的dialog,sweet Alert Dialog 导入Android Studio
系统自带的dialog实在是丑到无法忍受.所以找到了一款比较好的第三方dialog. github 地址如下:https://github.com/pedant/sweet-alert-dialog ...
- Android studio使用android:style/Theme.Dialog报错:You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
查找原因是在activity java代码部分继承了compatactivity public class DialogActivity extends AppCompatActivity 但是在An ...
- Android Studio快速开发之道
概述 现如今开发越来越追求效率和节奏,节省出时间做更多的事情,除了开发技术上的封装等,开发工具的使用技巧也是很重要的,今天就根据自己的经验来给大家介绍一下Android Studio快速开发之道. P ...
- Android Studio各种快捷功能及好用的插件
转载:http://www.jianshu.com/p/c439605a4364 概述 现如今开发越来越追求效率和节奏,节省出时间做更多的事情,除了开发技术上的封装等,开发工具的使用技巧也是很重要的, ...
- [原]在AMD机器上使用android studio
amd机器上使用android studio进行调试.因为amd的cpu不支持IntelVT,所以可能会有如下错误提示 我们有几个选择: 1. 使用真机调试 2. 配合genymotion 3. ...
- android studio 各种问题
1.dexDebug ExecException finished with non-zero exit value 2 全bug日志如下: (Error:Execution failed for t ...
- eclipse项目迁移到android studio(图文最新版)
前言 最近Android studio(下文简称AS)官方发布了正式版,目前火得不行.个人认为主要是因为android是google自家的产品,AS也是他自己搞的IDE,以后的趋势android开发肯 ...
- android studio遇到的问题(记录总结)
SDK 无法更新解决方案 这个问题不是Android Studio的问题,而且由一些一些众所周知的原因导致的,我们这里说下解决办法. 打开SDK Manager,停止更新连接:在界面上方找Tools- ...
- 在Android Studio中使用shareSDK进行社会化分享(图文教程)
[声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/4 ...
- android studio使用说明
一.学习的基本配置文档,搞好各种参数的基本配置,熟练使用. C:\Program Files\Java\jdk1.7.0_09\bin 二.problems meet in weather and ...
随机推荐
- IDEA中常见问题
idea中不存在.iml文件项目主目录下执行命令行mvn idea:module
- 云计算——实验3:AWS实验-EC2操作
本次实验属于验证型实验,通过本次实验学生将掌握以下内容: 1.EC2免费实例创建方法: 2.EC2实例SSH连接以及命令使用. 我使用阿里云进行注册和远程连接,aws需要使用信用卡,国内的比较省事. ...
- 力扣53. 最大子数组和(dp)
给你一个整数数组 nums ,请你找出一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和. 子数组 是数组中的一个连续部分. 示例 1: 输入:nums = [-2,1,-3,4,-1 ...
- hbase修改表TTL
创建表时可以指定TTL create 'test_lwt',{NAME=>'d',TTL=>3600} 设置test_lwt表数据TTL为3600秒 修改已存在的表TTL disable ...
- 【Windows】IP 地址变为 169.254.x.x 的解决方法
最近每次开机 IP 地址都会自动跳至 169.254.x.x 段,连接不上网络,设置了固定 IP 也会跳段.因此找到以下解决方法: 『IP地址变成169.254.x.x 和固定ip两个IP地址的解决办 ...
- php微信公众号开发之生成带参数的二维码
参考微信公众平台:https://developers.weixin.qq.com/doc/offiaccount/Account_Management/Generating_a_Parametric ...
- linux 查看端口号是否对外开放,并开放端口号
查看对外开放的端口状态查询指定端口是否已开 firewall-cmd --query-port=8780/tcp 提示 yes,表示开启:no表示未开启. 对外开发端口 查看想开的端口是否已开:fir ...
- TinyMapper使用 对象映射框架
方便的进行对象转换,仅作使用笔记 https://www.cnblogs.com/arvinzhang/p/8282922.html 例子: var result = new List<Equi ...
- 尝试在Ubuntu中安装Emacs遇到的问题
出现具体问题 今日学习安装emacs在Ubuntu19.04当中 安装详见下方帖子: 链接: 如何在Ubuntu中安装Emacs. 安装遇到问题,即 sudo add-apt-repository p ...
- 2019-2020-1 20199318《Linux内核原理与分析》第十二周作业
<Linux内核原理与分析> 第十二周作业 一.预备知识 Set-UID 是 Unix 系统中的一个重要的安全机制.当一个 Set-UID 程序运行的时候,它被假设为具有拥有者的权限.例如 ...