NetBlog主题

Android 设置和获取APP版本信息
Android基础

Android 设置和获取APP版本信息

2065

找到build.gradle 文件,设置版本信息 defaultConfig {applicationId "com.example.testapp"minSdkVersion 16targetSdkVersion 30versionCode 1versionName "1.01"testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"}获取版本信息/** 获取当前程序的版…

Android Java Http  get和post请求
Android基础

Android Java Http get和post请求

2126

public String get(String urlAddress) {try {URL url = new URL(urlAddress);HttpURLConnection connection = (HttpURLConnection) url.openConnection();//开启连接connection.connect();//连接服务器if (connection.getResponseCode() == 200) {//使用字符流形式进行回复In…

Android跨线程更新UI
Android基础

Android跨线程更新UI

1885

new Thread( new Runnable(){@Overridepublic void run() {final EditText editText=findViewById(R.id.et_1);//MainActivity为当前UI的 Activitynew Handler(MainActivity.this.getMainLooper()).post(new Runnable() {@Overridepublic void run() {editText.setText("新的内…

Android 操作SQLite数据库增删改查
Android基础

Android 操作SQLite数据库增删改查

5489

数据库帮助类public class DatabaseHelper extends SQLiteOpenHelper {//转载请保留 http://www.luofenming.com/show.aspx?id=ART2020100600001/*** 如果有SQLite数据文件 则不创建新的SQLite数据库文件* @param context 上下文* @param fileName 数据库文件名*/public Data…

Android Java IO写入与读取数据
Android基础

Android Java IO写入与读取数据

1588

public void save(String fileName,String content) {try {FileOutputStream fileOutputStream=openFileOutput(fileName,MODE_PRIVATE);fileOutputStream.write(content.getBytes());fileOutputStream.close();} catch (IOException e) {e.printStackTrace();}}public Str…

Android SharedPreferences轻量数据存储与读取
Android基础

Android SharedPreferences轻量数据存储与读取

1528

/** @fimeName 存储的文件名 为xml格式文件* @key 存储数据的键* @value 存储数据* */public void writeData(String fimeName, String key, String value) {// fileName文件名 MODE_PRIVATE 为防问权限 文件只能当前本应用读写SharedPreferences sharedPreferences = getSha…

自定义 Android 对话框
Android基础

自定义 Android 对话框

1806

在这用到了支持点有:方法传递、参数传递activity_custom_dialog.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_pare…

Android 内容使用浏览器WebView
Android基础

Android 内容使用浏览器WebView

1535

activity_web_view.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"WebViewandroid:id="@+id/wv_1"android:la…

自定义 Android AlertDialog  对话框
Android基础

自定义 Android AlertDialog 对话框

2328

自定义样式EditText边框样式 bg_edit.xml?xml version="1.0" encoding="utf-8"?shape xmlns:android="http://schemas.android.com/apk/res/android"strokeandroid:width="1dp"android:color="#999999"/strokecornersandroid:radius="10dp"/corners/shape…