安卓如何缓存文本框内容

两个文本框,在第一次进入App时,输入内容;退出App,再次进入时,保留上次填写的内容。怎么写,我好像也调用不了输入事件的addTextChangedListener方法。还有就是密码文本框怎么做到显示和隐藏

img


            <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 网络存储数据
具体文章参考如下:


用AutoCompleteTextView实现历史记录提示_iamkila的博客-CSDN博客 这画面不陌生吧,百度的提示,他的词库并不是历史记录,是搜索引擎收集的当前最常搜索的内容。假如我们也要在android的应用实现如上功能怎么做呢?方法很简单,android已经帮我们写好了api ,这里就用到了AutoCompleteTextView组件。       网上有不少教程,那个提示框字符集都是事先写好的,例如用一个String[] 数组去包含了这些数据,但是,我们也可以吧用户输入 https://blog.csdn.net/iamkila/article/details/7230160

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的显示变换就可以了

学着用数据读写吧,用户配置,各种设置都需要保存,总是要用到的