https://blog.csdn.net/qq_43133135/article/details/113199592 Android Studio安装教程(最新,最全,最详细,图超多)
https://cloud.tencent.com/developer/article/1743279 Android Studio使用USB真机调试详解
https://developer.android.com/studio/releases/platforms?hl=zh-cn SDK 平台版本说明 Android开发SDK版本号和API level对照表
1. 安装,记得配置: idea.config.path=D:\\Dev\\Tools\\android_studio_config
2. Android开发无法连接dl.google.com问题 https://www.jianshu.com/p/147081e7bc06
3. 增加到PATH = D:\Dev\Tools\Android_SDK\platform-tools
4. 无线: https://zhuanlan.zhihu.com/p/336660319
adb pair 192.168.0.113:42035 ,输入配对码。 这个ip到手机的无线调试,使用配对码配对设备,会显示出来。
然后到andorid studio,下拉设备下拉框,选择Device Manager—Physical–Pair using Wi-Fi
最后能在Available Wi-Fi devices看到,点后面的pair按钮,输入手机上的验证码。
模块的 build.gradle
1 2 3 4 5 6 7 |
//引入butterknife implementation 'com.jakewharton:butterknife:10.2.3' annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' //引入XUI implementation 'com.github.xuexiangjys:XUI:1.1.8' //引入fastjson implementation 'com.alibaba:fastjson:1.2.79' |
编译控制台乱码: Android Studio Build Output 栏内汉字出现乱码的解决方案 https://blog.csdn.net/zhang5690800/article/details/104502632
引入XUI
settings.gradle
1. 在 settings.gradle 加入一下内容:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
dependencyResolutionManagement { repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { ...... // 阿里镜像 maven { url 'https://maven.aliyun.com/repository/google' } maven { url 'https://maven.aliyun.com/repository/public' } maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } ...... // JitPack 远程仓库:https://jitpack.io maven { url 'https://jitpack.io' } ...... jcenter() // Warning: this repository is going to shut down soon } } |
2. 在工程模块下面的build.gradle, 加入一下内容:
1 2 3 4 5 |
dependencies { ...... implementation 'com.github.xuexiangjys:XUI:1.1.8' ...... } |
3. 更改主题:
1 2 3 4 5 6 |
<style name="Theme.MyApplication" parent="XUITheme.Phone"> <!-- 自定义自己的主题样式 --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> </style> |
也可以在代码初始化:
1 2 3 4 5 6 |
@Override protected void onCreate(Bundle savedInstanceState) { XUI.initTheme(this); super.onCreate(savedInstanceState); ... } |
如何确定Android设备唯一识别码 https://www.jianshu.com/p/52e14654e842
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/** * 自 Android 10(API 级别 29)起,您的应用必须是设备或个人资料所有者应用, * 具有特殊运营商许可,或具有 READ_PRIVILEGED_PHONE_STATE 特权, * 才能访问不可重置的设备标识符 * @return */ private String getDeviceId() { String deviceCode = null; if (Build.VERSION.SDK_INT > 28) { deviceCode = Settings.System.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID); } else { TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE); deviceCode = tm.getDeviceId(); } return deviceCode; } /** * 获得Android标志 * @return */ private String getAndroid(){ String androidId = Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID); return androidId; } |
Layout的标签
1 2 3 |
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" |
Shape参数说明
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape=["rectangle" | "oval" | "line" | "ring"] > <corners android:radius="integer" android:topLeftRadius="integer" android:topRightRadius="integer" android:bottomLeftRadius="integer" android:bottomRightRadius="integer" /> <gradient android:angle="integer" android:centerX="integer" android:centerY="integer" android:centerColor="integer" android:endColor="color" android:gradientRadius="integer" android:startColor="color" android:type=["linear" | "radial" | "sweep"] android:useLevel=["true" | "false"] /> <padding android:left="integer" android:top="integer" android:right="integer" android:bottom="integer" /> <size android:width="integer" android:height="integer" /> <solid android:color="color" /> <stroke android:width="integer" android:color="color" android:dashWidth="integer" android:dashGap="integer" /> </shape> |
StateListDrawable参数说明 https://www.twle.cn/l/yufei/android/android-basic-button.html
控件的背景样式 https://www.twle.cn/l/yufei/android/android-basic-textview3.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 设置透明背景色 --> <solid android:color="@color/color_0099e5" /> <!-- 渐变,会覆盖背景色 --> <!--<gradient android:angle="270" android:endColor="@color/red" android:startColor="@color/green" />--> <!-- 设置一个边框 --> <stroke android:width="2px" android:color="@color/c000dff" /> <!-- 设置四个圆角的半径 --> <corners android:bottomLeftRadius="15px" android:bottomRightRadius="15px" android:topLeftRadius="15px" android:topRightRadius="15px" /> <!-- 设置一下边距,让空间大一点 --> <padding android:bottom="5dp" android:left="5dp" android:right="5dp" android:top="5dp" /> </shape> |
按钮的状态背景样式 https://www.twle.cn/l/yufei/android/android-basic-button.html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
//dimens.xml //colors.xml //button_rounded.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <!-- 按钮被按下样式 --> <item android:state_pressed="true"> <shape> <solid android:color="@color/bbutton_danger_pressed" /> <!-- 渐变,会覆盖背景色 --> <!--<gradient android:angle="270" android:endColor="@color/red" android:startColor="@color/green" />--> <stroke android:width="1dp" android:color="@color/bbutton_danger_edge" /> <corners android:radius="@dimen/bbuton_rounded_corner_radius" /> </shape> </item> <!-- 按钮不可用样式 --> <item android:state_enabled="false"> <shape> <solid android:color="@color/bbutton_danger_disabled" /> <stroke android:width="1dp" android:color="@color/bbutton_danger_disabled_edge" /> <corners android:radius="@dimen/bbuton_rounded_corner_radius" /> </shape> </item> <!-- 按钮普通样式 --> <item> <shape> <solid android:color="@color/bbutton_danger" /> <stroke android:width="1dp" android:color="@color/bbutton_danger_edge" /> <corners android:radius="@dimen/bbuton_rounded_corner_radius" /> </shape> </item> </selector> |
自定义控件之 Android 事件机制 – 回调 https://www.twle.cn/l/yufei/android/android-basic-event-callback.html
自定义控件 WebView https://www.twle.cn/l/yufei/android/android-basic-webview-scrollby.html
android:layout_gravity 和 android:gravity 的区别 https://www.cnblogs.com/ghj1976/archive/2011/04/26/2029535.html
Activity 数据传递,多个 Activity 间的交互,关闭所有 Activity,完全退出,双击返回键退出程序,Activity 转场动画,Bundle 传递数据的限制,设置 Activity 全屏,定义对话框 ( Dialog ) 风格 https://www.twle.cn/l/yufei/android/android-basic-activity-start.html
TextView 边框 https://www.twle.cn/l/yufei/android/android-basic-textview3.html
Android Activity 数据传递 https://www.twle.cn/l/yufei/android/android-basic-activity-start.html
1 2 3 4 5 6 7 8 9 10 11 |
Intent intent = new Intent(MainActivity.this, T1Activity.class); intent.putExtra("key1","这是我的值111"); intent.putExtra("key2",1000); startActivity(intent); Intent intent = new Intent(MainActivity.this, T1Activity.class); Bundle bundle = new Bundle(); bundle.putString("key1","这是我的值222"); bundle.putInt("key2",2000); intent.putExtras(bundle); startActivity(intent); |
Android Intent 传递简单数据 https://www.twle.cn/l/yufei/android/android-basic-intent-simple.html
Android Intent 传递数组 https://www.twle.cn/l/yufei/android/android-basic-intent-array.html
Android Intent 传递集合 https://www.twle.cn/l/yufei/android/android-basic-intent-set.html
Android Intent 传递对象 https://www.twle.cn/l/yufei/android/android-basic-intent-object.html
Android Intent 传参 – Application 对象 https://www.twle.cn/l/yufei/android/android-basic-intent-global.html
android webview中视频播放及全屏(成功) https://www.jianshu.com/p/54ac34790db0
Android VideoView播放视频全屏 https://blog.csdn.net/qq_31939617/article/details/103627295
ExoPlayer的简单使用 https://www.jianshu.com/p/1851e9287d22
ExoPlayer详解(官方文档-入门) https://blog.csdn.net/qq_35864421/article/details/115345091
ExoPlayer最新文档 https://exoplayer.dev/hello-world.html
ExoPlayer简单使用 https://www.jianshu.com/p/6e466e112877
Android视频播放器ExoPlayer全屏 https://blog.csdn.net/greatyoulv/article/details/104023467
iPlayer 播放器 https://gitee.com/hty_Yuye/iPlayer
EditText android:inputType 值列表 https://www.twle.cn/l/yufei/android/android-basic-edittext3.html
按钮状态背景 https://www.twle.cn/l/yufei/android/android-basic-button.html
按钮圆角: https://www.twle.cn/l/yufei/android/android-basic-button.html
Button 按钮 自制水波效果 https://www.twle.cn/l/yufei/android/android-basic-button2.html Java代码实现
Android ProgressBar 自定义圆环进度条 https://www.twle.cn/l/yufei/android/android-basic-progressbar-custom.html
Android Adapter 适配器 https://www.twle.cn/l/yufei/android/android-basic-adapter.html
android中利用线程handler改变textView的内容 https://blog.csdn.net/hxy19971101/article/details/72684740
1 2 3 4 5 6 |
new Runnable() { @Override public void run() { textView1.setText(chronometer.getText() + "\n" + textView1.getText()); } }.run(); |
android进行异步更新UI的四种方式 https://segmentfault.com/a/1190000003702775
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
//1.使用Handler消息传递机制 new Handler(){ @Override public void handleMessage(@NonNull Message msg) { super.handleMessage(msg); System.out.println("msg=" + msg.what); textView1.setText("1.使用Handler消息传递机制: "+chronometer.getText()); } }.sendEmptyMessage(888); //2. 使用AsyncTask异步任务,官方新API已经标记过时 new AsyncTask<String,String,String>(){ @Override protected String doInBackground(String... strings) { return null; } @Override protected void onPostExecute(String s) { super.onPostExecute(s); textView2.setText("2. 使用AsyncTask异步任务: "+chronometer.getText()); } }.execute(); //3. 使用runOnUiThread(action)方法: new Thread(){ @Override public void run() { super.run(); runOnUiThread(new Runnable() { @Override public void run() { textView3.setText("3. 使用runOnUiThread(action)方法: "+chronometer.getText()); } }); } }.start(); //4. 使用Handler的post(Runnabel r)方法 new Handler().post(new Runnable() { @Override public void run() { textView4.setText("4. 使用Handler的post(Runnabel r)方法: "+chronometer.getText()); } }); //5. 使用Runnable方法 new Runnable() { @Override public void run() { textView5.setText("5. 使用Runnable方法: "+chronometer.getText()); } }.run(); |
对话框: 很详细例子 https://www.twle.cn/l/yufei/android/android-basic-alertdialog.html 使用适配器 参考: https://blog.csdn.net/sandalphon4869/article/details/100153479
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
//普通对话框 AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setIcon(R.drawable.a1) .setTitle("系统提示") .setMessage("这是一个最普通的 AlertDialog,\n带有三个按钮,分别是取消,普通和确定"); // 取消按钮 builder.setNegativeButton("取消", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(MainActivity.this, "你点击了取消按钮~", Toast.LENGTH_SHORT).show(); } }); // 确定按钮 builder.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(MainActivity.this, "你点击了确定按钮~", Toast.LENGTH_SHORT).show(); } }); // 普通按钮 builder.setNeutralButton("普通按钮", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(MainActivity.this, "你点击了普通按钮~", Toast.LENGTH_SHORT).show(); } }); AlertDialog dialog = builder.create(); // 创建 AlertDialog 对象 dialog.show(); // 显示对话框 //设定样式,只能通过代码 // 必须在对话框上调用show()才能访问按钮,这些按钮事先不可用 dialog.getButton(AlertDialog.BUTTON_POSITIVE).setBackground( ContextCompat.getDrawable(MainActivity.this, R.drawable.button_rounded) ); dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setBackground( ContextCompat.getDrawable(MainActivity.this, R.drawable.button_rounded) ); dialog.getButton(AlertDialog.BUTTON_NEUTRAL).setBackground( ContextCompat.getDrawable(MainActivity.this, R.drawable.button_rounded) ); |
日期选择
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Calendar cale1 = Calendar.getInstance(); DatePickerDialog datePickerDialog = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { String str = "你选择的是 " + year + "年" + (monthOfYear + 1) + "月" + dayOfMonth + "日"; Log.d(msg, "信息是:" + str); Toast.makeText(getApplicationContext(), str, Toast.LENGTH_SHORT).show(); } }, cale1.get(Calendar.YEAR), cale1.get(Calendar.MONTH), cale1.get(Calendar.DAY_OF_MONTH)); datePickerDialog.show(); datePickerDialog.getButton(AlertDialog.BUTTON_NEGATIVE).setBackground( ContextCompat.getDrawable(MainActivity.this, R.drawable.button_rounded) ); datePickerDialog.getButton(AlertDialog.BUTTON_POSITIVE).setBackground( ContextCompat.getDrawable(MainActivity.this, R.drawable.button_rounded) ); |
Android ActionBar和ToolBar的使用 https://www.jianshu.com/p/81d0bcb282cb
菜单OptionMenu https://www.twle.cn/l/yufei/android/android-basic-menu.html
ContextMenu 上下文菜单 https://www.twle.cn/l/yufei/android/android-basic-contextmenu.html
PopupMenu 弹出菜单 https://www.twle.cn/l/yufei/android/android-basic-popupmenu.html
DrawerLayout 侧滑菜单 https://www.twle.cn/l/yufei/android/android-basic-drawerlayout.html
DrawerLayout 左右侧滑菜单 https://www.twle.cn/l/yufei/android/android-basic-drawerlayout2.html
res\menu\main_optionmenu.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/create" android:title="新建" /> <item android:id="@+id/edit" android:title="编辑" /> <item android:id="@+id/save" android:title="保存" /> <item android:id="@+id/save_as" android:title="另存为..." /> <item android:id="@+id/help" android:title="帮助" /> </menu> ... // 1. 定义菜单项的标识 final private int OPEN = 111; @Override public boolean onCreateOptionsMenu(Menu menu) { // 加载 XML 菜单目录 getMenuInflater().inflate(R.menu.main_optionmenu, menu); menu.add(1,OPEN,0,"打开"); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // 菜单项被选中时触发 int id = item.getItemId(); String label = ""; Log.d("OptionMenu",String.valueOf(id)); switch (id){ case R.id.create: label = "新建"; break; case OPEN: label = "打开"; break; case R.id.help: label = "帮助"; break; } Toast.makeText(getApplicationContext(),"你点击了:" + label,Toast.LENGTH_SHORT).show(); return super.onOptionsItemSelected(item); } |
定时器
1 2 3 4 5 6 7 8 |
//使用定时器,每隔 100 毫秒让 handler 发送一个空信息 new Timer().schedule(new TimerTask() { @Override public void run() { myHandler.sendEmptyMessage(0x123); } }, 0,200); |
Activity 状态保存 横竖屏自动切换 https://www.twle.cn/l/yufei/android/android-basic-activity-savestate.html
Activity间和Fragment间的数据传递—使用Bundle https://blog.csdn.net/qunqunstyle99/article/details/82026124
WebView错误 net::ERR_CLEARTEXT_NOT_PERMITTED
1 2 3 4 5 6 7 8 9 10 11 |
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test.myapplication"> <uses-permission android:name="android.permission.INTERNET" /> <application ...... android:usesCleartextTraffic="true" > ...... </application> </manifest> |
WebView 问题解决:
Android WebView 使用 https://www.twle.cn/l/yufei/android/android-basic-webview.html
Webview加载界面白屏解决方法总结 https://www.cxymm.net/article/qq_34584049/78280815
解决页面退出 WebView 继续播放视频音乐的问题 https://blog.csdn.net/yy1300326388/article/details/72466875
Android-VideoView播放网络视频 m3u8格式 https://blog.csdn.net/qq_41113081/article/details/86689388
VideoView全屏视频播放 https://blog.csdn.net/kingroc/article/details/51108587
VideoView 视频播放完成例子(进度条,播放时间,暂停,拖动) https://cloud.tencent.com/developer/article/1361737
Android高版本联网失败报错:Cleartext HTTP traffic to xxx not permitted解决方法 https://blog.csdn.net/gengkui9897/article/details/82863966
Android 显示、隐藏状态栏和导航栏 https://www.jianshu.com/p/e9e443271c98
AlertDialog的按钮样式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
// 调用 show()方法后得到 dialog对象 AlertDialog dialog = builder.show(); final Button positiveButton = dialog.getButton(AlertDialog.BUTTON_POSITIVE); final Button negativeButton=dialog.getButton(AlertDialog.BUTTON_NEGATIVE); LinearLayout.LayoutParams positiveParams =(LinearLayout.LayoutParams)positiveButton.getLayoutParams(); positiveParams.gravity = Gravity.CENTER; positiveParams.setMargins(10,10,10,10); positiveParams.width = 0; // 安卓下面有三个位置的按钮,默认权重为 1,设置成 500或更大才能让两个按钮看起来均分 positiveParams.weight = 500; LinearLayout.LayoutParams negativeParams =(LinearLayout.LayoutParams)negativeButton.getLayoutParams(); negativeParams.gravity = Gravity.CENTER; negativeParams.setMargins(10,10,10,10); negativeParams.width = 0; negativeParams.weight = 500; positiveButton.setLayoutParams(positiveParams); negativeButton.setLayoutParams(negativeParams); positiveButton.setBackgroundColor(Color.parseColor("#FF733E")); positiveButton.setTextColor(Color.parseColor("#FFFFFF")); negativeButton.setBackgroundColor(Color.parseColor("#DDDDDD")); |
Android禁止锁屏,保持常亮方法 https://blog.csdn.net/qq_17766199/article/details/50118291
ListView的滚动监听–AbsListView.OnScrollListener的学习 https://www.jianshu.com/p/0b731f38120e
Textview 文本旋转,倾斜 https://blog.csdn.net/u014649598/article/details/45563723
Android之网络图片加载的5种基本方式 https://blog.csdn.net/DickyQie/article/details/59146221
如何设置WebView支持js的Alert,Confirm,Prompt函数的弹出提示框 https://blog.csdn.net/mChenys/article/details/49930739
Android中下载apk文件并安装 : https://blog.csdn.net/zhaihaohao1/article/details/81808902
Android 创建文件夹失败(File.mkdirs()) https://www.jianshu.com/p/cd9d45afaddb
解决Android 7.0及以上版本文件暴露异常exposed beyond app through Intent.getData()的方法 https://www.codeleading.com/article/24892804593/
在WebView中获取网页源码 https://blog.csdn.net/qq_32452623/article/details/52182964 https://www.jianshu.com/p/04a0e30771f4
Android 显示、隐藏状态栏和导航栏 https://www.jianshu.com/p/c545b1496c5e