更新时间: 试题数量: 购买人数: 提供作者:

有效期: 个月

章节介绍: 共有个章节

收藏
搜索
题库预览
请设计一个简单的Android应用程序,需要设计登录页面,并将这些信息保存到一个文本文件中。当用户打开应用程序时,他们可以查看并编辑这些信息。( )

xmlns:android="http://schemas.android.com/apk/res/android"  

    xmlns:tools="http://schemas.android.com/tools"  

    android:layout_width="match_parent"  

    android:layout_height="match_parent"  

    android:padding="16dp" >  

  

    <EditText  

        android:id="@+id/nameEditText"  

        android:layout_width=" _________"  

        android:layout_height="_________"  

        android:hint="请输入姓名" />  

  

    <EditText  

        android:id="@+id/passwordText"  

        android:layout_width=" match_parent "  

        android:layout_height=" wrap_content "  

        android:hint="请输入密码" />  

  

    <Button  

        android:id="@+id/saveButton"  

        android:layout_width=" match_parent "  

        android:layout_height=" wrap_content "  

        android:text="保存" />  

  

</LinearLayout>

  MainActivity.java username_et = findViewById(R.id. nameEditText); password_et = findViewById(R.id. passwordText); String username = username_et.______; String password = password_et. getText().toString(); SharedPreferences sp = getSharedPreferences("demo", MODE_PRIVATE); SharedPreferences.Editor editor = sp._______; editor.putString("username", username); editor.putString("password", password); editor.______;

1 2