@SerializedName
value:填的是对应json数据上的字段名(序列化)
alternate:Java model类转为json时,这个字段对应json上面的哪个字段用这个(反序列化)
Android流行UI布局——底部导航
参考:Android流行UI布局——底部导航(BottomNavigationView+ViewPager+Fragment) - 简书
1、导包
2、在res下的Menu文件夹中创建menu菜单
3、布局文件,viewpager标签和buttomNavigationView标签(View标签可以做背景效果)
4、Fragment文件
5、添加监听事件,实现ViewPager的适配器
bottomNavigationView.setOnNavigationItemSelectedListener
viewPager.addOnPageChangeListener
6、通过适配器将Fragment添加到Viewpager中
约束布局(ConstraintLayout)
参考:约束布局ConstraintLayout使用详解 - 简书
1、常用属性:
layout_constraintLeft_toLeftOf
layout_constraintLeft_toRightOf
layout_constraintRight_toLeftOf
layout_constraintRight_toRightOf
layout_constraintTop_toTopOf
layout_constraintTop_toBottomOf
layout_constraintBottom_toTopOf
layout_constraintBottom_toBottomOf
layout_constraintBaseline_toBaselineOf
layout_constraintStart_toEndOf
layout_constraintStart_toStartOf
layout_constraintEnd_toStartOf
layout_constraintEnd_toEndOf
其中左右一般用start和end这两个
2、官方在约束布局中不推荐使用match_parent,推荐使用0dp配合约束代替
3、链条
layout_constraintHorizontal_chainStyle和 layout_constraintVertical_chainStyle
spread,spread_inside,packed 三种样式
Field
1、为我们提供了获取当前对象的成员变量的类型,和重新设值的方法
2、getType()方法返回的是Class<?>类型的,而getGenericType()返回的是Type类型的
3、getDeclaredField("想要获得的变量名"),但仅能获取类本身的属性成员(包括私有、共有、保护)
4、setAccessible(true) 在Java中可以通过反射进行获取实体类中的字段值,当未设置Field的setAccessible方法为true时,会在调用的时候进行访问安全检查,会抛出IllegalAccessException异常