
安卓
大不懂
哈哈哈哈
展开
-
TextInputLayout的基本使用
TextInputLayout属于EditText的一个浮动标签,属于Material Design 设计规范中的,效果可以看下面的动图账号:只是普通EditText密码:用TextInputLayout包裹的EditText使用的话TextInputLayout包裹一个EditText就可以。当然TextInputLayout也只能包裹EditText:<android.support.design.widget.TextInputLayout android:id=.原创 2020-12-03 09:11:34 · 3341 阅读 · 0 评论 -
SurfaceView导致DrawerLayout显示不全
我们在华为的pad算上使用DrawerLayout限制不全,查看发现页面底部使用了SurfaceView,最终的解决办法是:drawerlayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() { @Override public void onDrawerSlide(View drawerView, float slideOffset) { // TODO Auto-generat...原创 2020-10-19 10:16:23 · 463 阅读 · 0 评论 -
getResources.getColor过时
在android 23(6.0)及以上getResources.getColor(R.color.colorId)API过时时,那么它的替代方法为ContextCompat.getColor(context,R.color.colorId);可以使用最新的V4兼容包中的ContextCompat,这样也可以兼容低版本的平台...原创 2020-09-23 16:04:08 · 592 阅读 · 3 评论 -
读取Assets目录下的text
读取Assets目录下的text,逐行读取。try { InputStream is = getAssets().open("infoData1.txt"); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = br.readLine(); int i = 0; while (line != null) { line = br.readL.原创 2020-09-17 13:22:35 · 299 阅读 · 3 评论 -
ADB常见命令
查看驱动:adb devices查看链接设备的IP:adb shell ifconfig wlan0关闭驱动:adb kill server打开驱动:adb start-server链接驱动:adb connect 192.168.200.170打开某个apk:adb shell am start com.wanji.v2x20200806/.ui.activity.MainActivity adb shell am start 包名/.主...原创 2020-09-09 20:54:34 · 615 阅读 · 3 评论 -
关于MaterialDesign的综合使用
下图是根基前面几篇文章聚合成一个的:Android MaterialDesign简单使用_toolbar:https://blog.youkuaiyun.com/qq_35698774/article/details/107892669Android MaterialDesign简单使用_DrawerLayout:https://blog.youkuaiyun.com/qq_35698774/article/details/107894719悬浮按钮和可交互按钮:https://blog.youkuaiyun.com/qq_356原创 2020-08-22 18:02:31 · 268 阅读 · 2 评论 -
SwipeRefreshLayout
SwipeRefreshLayout是用于实现下拉刷新的核心类,使用很简单只需要使用SwipeRefreshLayout将Recyclerview包裹一下就行。使用:xml:<androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/srl" android:layout_width="match_parent" android:layout_height="match_par原创 2020-08-22 14:34:44 · 1964 阅读 · 3 评论 -
CardView的基本使用
CardView是用于实现卡片式布局效果的重要控件,实际上也是一个frameLayout,只是额外提供了圆角和阴影,看上去有立体效果。效果如下:<?xml version="1.0" encoding="utf-8"?><androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http:...原创 2020-08-19 22:30:49 · 26765 阅读 · 2 评论 -
CMake Warning
CMake Warning at H:/SDK/ndk/16.1.4479499/build/cmake/android.toolchain.cmake:243 (message):armeabi is deprecated and will be removed in a future NDK release.Call Stack (most recent call first):H:/SDK/cmake/3.10.2.4988404/share/cmake-3.10/Modules/CMakeDe原创 2020-08-10 14:54:58 · 1077 阅读 · 2 评论 -
Android中Service的生命周期
Service的声明周期相比于activity的声明周期要简单的多。下图就是来自https://developer.android.google.cn/guide/components/services#Lifecycle的图片。我们写一个myservice:package com.example.myservice;import android.app.Service;import android.content.Intent;import android.os.Binder;im原创 2020-07-27 21:00:59 · 564 阅读 · 2 评论 -
Service的简单使用
简介Service是一个服务,android的四大组件之一。他的使用也很简单。建立服务首先我们新建一个Sercve,点击右键New->Service->Service:然后:我们将服务命名为Myservice2,Exported属性表示是否允许除了当前程序之外其他的程序访问这个程序,Enabled表示是否启用这个服务。public class MyService2 extends Service { public MyService2() { }原创 2020-07-26 17:35:33 · 3640 阅读 · 2 评论 -
解决Listview更新IllegalStateException异常
当我们在使用listview时,数据在跟新的时候频繁滑动容易造成此异常,java.lang.IllegalStateException:。非法状态异常。报以下错误。java.lang.IllegalStateException: The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not mo...原创 2020-07-15 17:43:06 · 675 阅读 · 2 评论 -
OkHttp的基本使用
OkHttp是由Square公司开发的。地址:https://github.com/square/okhttp引入项目:dependencies {implementation("com.squareup.okhttp3:okhttp:4.8.0")}获取数据: private void sengRequestWithOkHttp(final String s) { new Thread(new Runnable() { ...原创 2020-07-12 23:42:17 · 1532 阅读 · 2 评论 -
HttpURLConnection
在Android上发送HTTP请求一般有两种一种是HttpURLConnection,另一种是HttpClinet,由于httpClient存在API数量过多,扩展困难等缺点,不建议使用,并且在Android6.0系统中被移除。 以下是介绍HttpURLConnection的使用方法。private void sendRequestWithHttp() { new Thread(new Runnable() { @Overrid...原创 2020-07-12 23:17:36 · 334 阅读 · 2 评论 -
WebView的基本使用
WebView是一android的View类的扩展类,可将网页显示为 Activity 布局的一部分。它不会包含功能全面的网络浏览器的任何功能,例如导航控件或地址栏。WebView默认只显示网页。 基本用法:xml:<?xml version="1.0" encoding="utf-8"?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schem...原创 2020-07-12 22:58:32 · 344 阅读 · 2 评论 -
Android 播放视频
视屏播放主要使用VideoView来实现。他将视屏的显示和控制集一身,使用它可以做一个简单的视频播放器。File file = new File(Environment.getExternalStorageDirectory(), path);videoView.setVideoPath(file.getPath()); // 指定视频文件的路径videoView.start(); // 开始播放videoView.pause(); // 暂停播放videoVi...原创 2020-06-30 23:48:55 · 740 阅读 · 3 评论 -
Android音频播放
在Android中播放音频文件一般使用MediaPlayer类来实现,他对多种格式的音频文件提供了非常全面的控制方法,从而使得播放器变得十分简单。File file = new File(Environment.getExternalStorageDirectory(), "456.mp3");mediaPlayer.setDataSource(file.getPath()); // 指定音频文件的路径mediaPlayer.prepare(); // 让MediaPlaye...原创 2020-06-30 23:36:08 · 2880 阅读 · 7 评论 -
适配android7.0 FileUriExposeException
当android7.0以上打开相机拍一张照片,存储的时候崩溃,报FileUriExposeException异常。原因是7.0以后直接使用本地路径的uri被认为是不安全的。具体解释:https://developer.android.google.cn/reference/android/os/FileUriExposedException.html翻译一下: 当应用程序file://Uri向其他应用程序公开时引发的异常。不推荐这种方法,因为接收方的应用程序可能无...原创 2020-06-28 20:52:43 · 385 阅读 · 2 评论 -
Android数据存储_LitePal
LitePal是一款开源的Android数据库框架,它采用了对象关系映射(ORM)的模式,并将我们平时开发时最常用到的一些数据库功能进行了封装,使得不用编写一行SQL语句就可以完成各种建表、増删改查的操作。并且LitePal很“轻”,jar包只有100k不到,而且近乎零配置,这一点和Hibernate这类的框架有很大区别。目前LitePal的源码已经托管到了GitHub上,地址是https://github.com/LitePalFramework/LitePal。...原创 2020-06-15 21:51:32 · 702 阅读 · 2 评论 -
Android数据存储_文件存储
Android数据存储的方式有种,主要有三种...原创 2020-06-10 11:14:53 · 919 阅读 · 3 评论 -
android广播机制(三)
使用广播一键下线原创 2020-06-08 19:25:17 · 365 阅读 · 2 评论 -
android广播机制(二)
上篇已经介绍过了广播的基本内容,这里介绍自定义广播。发送标准广播发送有序广播原创 2020-06-05 16:53:18 · 403 阅读 · 2 评论