Androidstudio 最新版本导入import android.support.v7.app.AlertDialog;
时间: 2023-10-09 08:14:19 浏览: 89
如果你的Android Studio版本是4.0及以上,那么应该使用`androidx.appcompat.app.AlertDialog`,而不是`android.support.v7.app.AlertDialog`。
如果你需要使用旧版的`support`库,可以在`build.gradle`文件中添加以下依赖:
```
implementation 'com.android.support:appcompat-v7:28.0.0'
```
但是建议使用最新版的`AndroidX`库,添加以下依赖:
```
implementation 'androidx.appcompat:appcompat:1.2.0'
```
然后使用`androidx.appcompat.app.AlertDialog`代替`android.support.v7.app.AlertDialog`。
相关问题
import android.app.AlertDialog;
这是一行 Android 开发中的代码,用于导入 AlertDialog 类。AlertDialog 是一个弹出式对话框,常用于提示用户或让用户做出选择。在使用 AlertDialog 前需要先创建一个 AlertDialog.Builder 对象,然后调用其 setXXX 方法设置对话框的属性,最后调用 create 方法创建对话框并显示。
package com.example.login; import androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.SimpleCursorAdapter; import android.app.AlertDialog; import android.content.DialogInterface; import android.widget.Spinner; import android.widget.Toast;
这是一个 Android 应用程序中的 Java 代码片段,用于实现一个登录功能。它包含了一些 Android 库的导入,如 `AppCompatActivity`,`ListView` 等等。这段代码还实现了与数据库的交互,通过 `SQLiteDatabase`、`Cursor`、`ContentValues` 等类进行数据的增删改查操作。此外,还包含了一些 UI 组件的定义,如 `EditText`、`Button`、`Spinner` 等等。最后,还有一些弹出框的实现,如 `AlertDialog`、`Toast` 等等。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)