- 博客(19)
- 收藏
- 关注
原创 复制的项目打不开
错误提示:Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [id 'com.android.application']Caused by: org.gradle.api.tasks.StopExecutionException: Your project path contains non-ASCII characters. This will most likely
2022-06-13 16:26:57
703
原创 Java创建文件夹和文件
/** * (1)判断e盘下是否有文件夹mytemp,如果没有就创建 * (2)在mytemp文件夹下创建文件hello.txt * (3)如果该文件已存在,提示已存在,就不要再重复创建了 * (4)在文件中写入hello,world~ */public class HomeWork01 { public static void main(String[] args) throws IOException { String directoryPath = "e:\\my.
2022-04-27 22:50:35
8181
原创 Java序列化保存数据和反序列化读取数据
1.序列化保存public class ObjectOutPutStream_ { public static void main(String[] args) throws Exception { //序列化后保存的文件格式,不是纯文本,而是按照它的格式来保存 String filePath = "e:\\data.dat"; ObjectOutputStream oos = new ObjectOutputStream(new FileOut
2022-04-26 10:41:43
1343
原创 Java使用处理流BufferedReader和BufferedWriter
public class BufferedReader_ { public static void main(String[] args) throws Exception { String filePath = "e:\\note.txt"; //创建BufferedReader对象 BufferedReader bufferedReader = new BufferedReader(new FileReader(filePath)); .
2022-04-25 10:08:25
450
原创 Java写入字符FileWriter
public class FileWriter_ { public static void main(String[] args) { String filePath = "e:\\note.txt"; FileWriter fileWriter = null; char[] chars = {'a','b','c'}; try { fileWriter = new FileWriter(filePath);.
2022-04-24 23:09:29
496
原创 Java文件复制(拷贝)
/** * 完成文件拷贝,将e盘文件拷贝到d盘 * 1.创建文件的输入流,将文件读入到程序 * 2.创建文件的输出流,将读取的文件写入到指定的文件 */public class FileCopy { public static void main(String[] args) { String srcFilePath = "e:\\图片素材\\img.jpg";//要拷贝的文件路径 String destFilePath = "d:\\img.jpg";/.
2022-04-24 10:10:09
831
原创 Android使用FastJson解析数据
使用前需要添加依赖implementation 'com.alibaba:fastjson:1.1.72.android' //将json格式的字符串转换为java对象 private void jsonToJavaObjectByFastJson() { //获取或创建JSON数据 String json = "{\n" + " \"id\":2,\n" + " \"name\":
2022-04-13 11:09:24
1604
1
原创 Android使用Gson解析数据
使用Gson前需要添加依赖或者添加jar包添加jar包:下载Gson的jar包,放在android项目的libs文件夹里,右键jar包,点击Add As Libary...1.将json格式的字符串转换为java对象 //将json格式的字符串转换为java对象 private void jsonToJavaObjectByGson() { //获取或创建JSON数据 String json = "{\n" + "
2022-04-13 10:01:08
3221
原创 手动JSON数据解析
1.将json格式的字符串{}转化为JAVA对象//第一步:获取或创建Json数据 String json = "{\n" + " \"id\":2,\"name\":\"小龙虾\",\n" + " \"price\":12.3,\n" + " \"imagePath\":\"https://192.168.10.165:80
2022-04-12 22:08:02
2925
原创 Android Include的使用,获取include 里面的控件
include 就是在一个布局中引入另一个布局,include 可以使相同的页面就写一次,提高了共同布局的复用性。1.先定义一个共用的布局<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="
2022-04-07 22:59:20
3756
原创 Android自定义View、ViewGroup
自定义View1.自定义属性在values目录下创建一个attrs.xml文件<?xml version="1.0" encoding="utf-8"?><resources> <declare-styleable name="MNView"> <attr name="mn_color" format="string"></attr> <attr name="mn_size" forma
2022-04-06 23:08:35
1662
原创 ViewPager和PagerTitleStrip(PagerTabStrip)的使用
第一步:添加布局ViewPager,PagerTitleStrip必须是ViewPager的直接子级<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://sc
2022-03-23 21:48:27
2659
原创 Android程序运行时申请权限(例:拨打电话)
public class MainActivity extends AppCompatActivity { private Button makeCall; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); m.
2022-03-21 23:50:53
3327
原创 Android广播注册
Broadcast(广播)是一种广泛应用在应用程序之间传输信息的机制,而BroadcastReceiver(广播接收器)则是用于接收来自系统和应用的广播并对其进行响应的组件。Android提供了一套完整的API,允许应用程序自由地发送和接收广播,其中用到可以传递信息的Intent。广播有动态注册和静态注册动态注册:必须在程序启动以后才能接收到广播public class MainActivity extends AppCompatActivity { private IntentFil
2022-03-18 23:39:27
3585
原创 Git Gui
上传文件1.进入需要上传文件的文件夹中,鼠标右键,选择Git Gui Here2.点击Create New Repository,Directory, 需要输入的路径就是想要上传的项目所在的文件夹,然后点击create.3.Rescan:搜索有差异的文档。Stage Changeed:把有差异的文件放入缓存区Sign Off:标签Commit:提交Push:把提交后的内容传到对应的github注:提交的内容需要有变化4.与github建立关联需要在github上建立仓
2022-03-17 22:39:32
434
原创 约束布局constraintlayout
约束布局:最少给一个控件两条边设置属性才能固定住控件1.控件在左上角:控件的左边对父容器的左边,控件的上边对父容器的上边app:layout_constraintLeft_toLeftOf="parent"app:layout_constraintTop_toTopOf="parent" 或app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent"left-----s
2022-03-17 16:05:19
1450
原创 强引用弱引用
java垃圾回收-强引用、软引用、弱引用、虚引用强引用(StrongReference)、软引用(Soft Reference) 、弱引用(Weak Reference) 和虚引用(Phantom Reference) 4种,这4种引用强度依次逐渐减弱强引用(StrongReference)-----OOM也不回收 最传统的“引用”的定义,...
2022-03-17 16:03:04
75
原创 怎么拿到自定义dialog弹窗的EditText
//创建相册的弹窗 public void createPhoto() { AlertDialog.Builder builder = new AlertDialog.Builder(this); View view = getLayoutInflater().inflate(R.layout.dialog_edittext, null); //R.layout.dialog_edittext为自定义布局 final EditTe...
2022-03-05 01:02:36
2077
原创 Activity传递数据给Fragment
Activity里的代码 //1.获取fragmentManager FragmentManager fragmentManager = getSupportFragmentManager(); //2.获取FragmentTransaction FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); //3.创建需要添加的.
2022-03-04 09:57:43
696
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人