xjbjava
转义字符\t 制表符 \n 换行符 \ \ 一个\ \ “ 一个” \ ‘ 一个’
八大基本数据类型数值型:整数类型(byte,short,int,long)、浮点类型(float,double)
字符型:(char) char类型为2个字节,本质就是一个数值
布尔型:(boolean)
整数型byte 1字节 -128~127
short 2字节
int 4字节
long 长整型 8字节
出现在代码中的整数,默认为int。声明long常量需后面加L或l
浮点型float 4字节
double 8字节
出现在代码中的小数,默认为double。声明float常量需后面加F或f
字符型char 2字节,可以用来存汉字,char的本质是一个整数,输出的是unicode码对应的字符。如果非要输出一个整数,需要强制转换(int)
布尔型boolean 1字节
自动类型转换数据类型按精度大小排序char -> int -> long -> float -> double
byte -> short -> int -> long -> ...
Fragment
FragmentFragment的产生
什么是Fragment
Fragment的使用方法MainActivity.javapackage a.b.c.fragmentbase;import android.os.Bundle;import androidx.activity.EdgeToEdge;import androidx.appcompat.app.AppCompatActivity;import androidx.core.graphics.Insets;import androidx.core.view.ViewCompat;import androidx.core.view.WindowInsetsCompat;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ...
ViewPager
MainActivitypackage a.b.c.viewpager;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import androidx.activity.EdgeToEdge;import androidx.appcompat.app.AppCompatActivity;import androidx.core.graphics.Insets;import androidx.core.view.ViewCompat;import androidx.core.view.WindowInsetsCompat;import androidx.viewpager.widget.ViewPager;import java.util.ArrayList;import java.util.List;public class MainActivity extends AppCompatActivity { @Override protecte ...
单位和尺寸
package a.b.c.layoutparams;import android.os.Bundle;import android.view.View;import android.view.ViewGroup;import android.widget.LinearLayout;import android.widget.TextView;import androidx.activity.EdgeToEdge;import androidx.appcompat.app.AppCompatActivity;import androidx.core.graphics.Insets;import androidx.core.view.ViewCompat;import androidx.core.view.WindowInsetsCompat;public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceSt ...
动画
逐帧动画定义:把几张图片快速播放形成的一个效果
MainActivitypackage a.b.c.lele_anim;import android.graphics.drawable.AnimationDrawable;import android.os.Bundle;import android.view.View;import android.widget.RelativeLayout;import androidx.activity.EdgeToEdge;import androidx.appcompat.app.AppCompatActivity;import androidx.core.graphics.Insets;import androidx.core.view.ViewCompat;import androidx.core.view.WindowInsetsCompat;public class MainActivity extends AppCompatActivity{ private boolean flag = true; @Ov ...
ListView and RecyclerView
ListViewMainActivitypackage a.b.c.lelelistview;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.AdapterView;import android.widget.ListView;import androidx.activity.EdgeToEdge;import androidx.appcompat.app.AppCompatActivity;import androidx.core.graphics.Insets;import androidx.core.view.ViewCompat;import androidx.core.view.WindowInsetsCompat;import java.util.ArrayList;import java.util.List;public class MainActivity extends AppCompatActivity{ p ...
Android布局
LinearLayout
<?xml version="1.0" encoding="utf-8"?><LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" > <LinearLayout android:layout_width="100dp" android:layout_height="100dp" android:background="#ff0000" /> <LinearL ...
Android控件
TextView基础属性详解
<?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" android:orientation="vertical" > <TextView android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/tv_one" android:text ...
Java基础项目
Animal类import java.time.LocalDate;public class Customer { private String name; private int visitCount; private LocalDate latestVisitDate; public Customer(String name, int visitCount, LocalDate latestVisitDate) { this.name = name; this.visitCount = visitCount; this.latestVisitDate = latestVisitDate; } @Override public String toString() { return "顾客 [name=" + name + ", visitCount=" + visitCount + ", lates ...