ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

Android 开发 - layout_editor_absoluteX 与 layout_editor_absoluteY、PreferenceManager

Android 开发 - layout_editor_absoluteX 与 layout_editor_absoluteY、PreferenceManager

layout_editor_absoluteX 与 layout_editor_absoluteY

  1. tools:layout_editor_absoluteX:在布局编辑器中指定 View 的 X 坐标

  2. tools:layout_editor_absoluteY:在布局编辑器中指定 View 的 Y 坐标

  • 这两个是 Android Studio 布局编辑器的预览辅助属性,并不是 Android 系统运行时使用的属性

PreferenceManager

SharedPreferencessharedPreferences=PreferenceManager.getDefaultSharedPreferences(this);SharedPreferences.Editoreditor=sharedPreferences.edit();// 写入数据editor.putString("username","John");editor.putInt("user_age",25);editor.putBoolean("notifications",true);editor.apply();// 读取数据Stringusername=sharedPreferences.getString("username","default");intage=sharedPreferences.getInt("user_age",0);booleannotifications=sharedPreferences.getBoolean("notifications",false);Log.d(TAG,"username: "+username);Log.d(TAG,"age: "+age);Log.d(TAG,"notifications: "+notifications);
# 输出结果 username: John age: 25 notifications: true
返回列表