两个文本框,在第一次进入App时,输入内容;退出App,再次进入时,保留上次填写的内容。怎么写,我好像也调用不了输入事件的addTextChangedListener方法。还有就是密码文本框怎么做到显示和隐藏
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:layout_width="@dimen/dp_100"
android:layout_height="match_parent"
android:gravity="center"
android:text="用户名:"
android:textSize="@dimen/sp_18"
android:textColor="@color/color_242424"/>
<EditText
android:id="@+id/Name_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/activity_item_bg"
android:paddingLeft="@dimen/dp_7"
android:gravity="center_vertical"
android:singleLine="true"
android:hint="请输入真实姓名"/>
LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="@dimen/dp_7"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:layout_width="@dimen/dp_100"
android:layout_height="match_parent"
android:gravity="center"
android:text="密码:"
android:textSize="@dimen/sp_18"
android:textColor="@color/color_242424"/>
<EditText
android:id="@+id/password_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/activity_item_bg"
android:inputType="textPassword"
android:paddingLeft="@dimen/dp_7"
android:gravity="center_vertical"
android:singleLine="true"
android:hint="请输入密码"/>
LinearLayout>
用SharedPreferences进行缓存;
Android应用开发中,给我们提供了5种数据的存储方式
1 使用SharedPreferences存储数据
2 文件存储数据
3 SQLite数据库存储数据
4 使用ContentProvider存储数据
5 网络存储数据
具体文章参考如下:
http://m.zhishizhan.net/show/38_101679.html
问题1、安卓文本框内容如何保留上次填写的内容。
提供参考实例分享【Android EditText输入框实现下拉且保存最近5个历史记录思路详解】,链接:https://www.jb51.net/article/216802.htm
问题2、安卓密码文本框怎么做到显示和隐藏
提供参考实例分享【Android EditText 之密码输入框显示和隐藏切换的实现】,
链接:http://www.ay1.cc/article/10460.html
问题一:自动存储和填充
Android应用开发中,有好多种数据的存储方式,一般像这种我们使用的SharedPreferences存储数据,当然为了数据安全,可以考虑使用文件、sqlite、网络请求等
问题二:密码文本框怎么做到显示和隐藏
其实就是edittext右端有一个显示和隐藏按钮,操作这个按钮,进行不同的edittext的显示变换就可以了
学着用数据读写吧,用户配置,各种设置都需要保存,总是要用到的