皮皮学,免费搜题
登录
搜题
【简答题】
请补全下面代码,实现将数据写入手机本地文件中。每空2分,共20分。 import java.util.Map; import android.annotation.SuppressLint; import android.os.Bundle; import android.text.TextUtils; import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; public class MainActivity extends AppCompatActivity implements OnClickListener { private static final String TAG = "MainActivity"; private EditText et_username; private EditText et_pwd; private CheckBox cb_checked; private Button bt_login; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); et_username = (EditText) this.findViewById(R.id.et_username); et_pwd = (EditText) this.findViewById(R.id.et_pwd); cb_checked = (CheckBox) this.findViewById(R.id.cb_checked); bt_login = (Button) this.findViewById(R.id.bt_login); bt_login.setOnClickListener(this); Map map = FileIntoDev. 第一空2分)(this); if (map != null) { et_username.setText(第二空2分)); et_pwd.setText( ); } } @SuppressLint("ShowToast") @Override public void onClick(View v) { String userName = et_username.getText().toString().trim(); String userPwd = et_pwd.getText().toString().trim(); Log.e("onClick",userName); Log.e("onClick",userPwd); if (TextUtils.isEmpty(userName) || TextUtils.isEmpty(userPwd)) { Toast.makeText(this, "用户名为空或用户密码为空", Toast.LENGTH_SHORT).show(); } else { if (cb_checked.isChecked()) { if (FileIntoDev.saveFileUserInfo( )) { Log.i(TAG, "用戶名和密码保存成功"); Toast.makeText(this, "用戶名和密码保存成功", Toast.LENGTH_SHORT).show(); } }else { if (FileIntoDev.saveFileUserInfo(this, userName,null)) { Log.i(TAG, "用戶名保存成功"); Toast.makeText(this, "用戶名保存成功", Toast.LENGTH_SHORT).show(); } } } } } import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import android.content.Context; public class FileIntoDev { public static boolean saveFileUserInfo(Context context, String username, String Pwd) { File file = new File( , "userinfo.txt"); try { FileOutputStream userFileout = new FileOutputStream( ); userFileout.write((username + "," + Pwd).getBytes()); userFileout. ; return true; } catch (Exception e) { e.printStackTrace(); return false; } } //从文件中读取用户的信息,并保存在Map对象中 從context.getFilesDir()中获得文件目录 public static Map getUserInfo(Context context) { File file = new File(context.getFilesDir(), "userinfo.txt"); FileInputStream userFilein; try { userFilein = new FileInputStream(); BufferedReader bufferedReader = new BufferedReader( ; String str = bufferedReader.readLine(); String userinfos[] = str.split(","); Map map = new HashMap (); map.put("username", userinfos[0]); map.put("userpwd", userinfos[1]); return ; } catch (Exception e) { e.printStackTrace(); return null; } } }
拍照语音搜题,微信中搜索"皮皮学"使用
参考答案:
参考解析:
知识点:
.
..
皮皮学刷刷变学霸
举一反三
【多选题】可逆储存氢的方法包括( )。
A.
高压气态储氢
B.
液氢
C.
金属氢化物
D.
物理吸附
E.
复杂氢化物
F.
碱性金属或化合物等直接水解制氢剂
G.
有机液态化合物
【多选题】多选(2分)尊重人的尊严的原则的主要内容是指在研究中,研究对象有哪几种权益:
A.
自主决定权
B.
隐私权
C.
匿名权
D.
保密权
【多选题】氢气的储存方法有( )。
A.
高压储氢
B.
低温储氢
C.
金属氢
D.
储氢合金储氢
【简答题】尊重人的尊严的原则的主要内容是指在研究中,研究对象有哪几种权益:
【多选题】拜金主义、享乐主义、极端个人主义等错误的人生观,其共同的特征是
A.
没有正确把握个人与社会的辩证关系
B.
忽视或否认社会性是人的存在和活动的本质属性
C.
对人的需要的理解极端、狭隘和片面
D.
其出发点和落脚点都是一己之私利
【简答题】目前氢能的储存有高压气态储存、低温液氢储存和()储存三种方法。
【单选题】近年来,一种新型简便的储氢方法应运而生,即利用储氢合金(金属氢化物)来储存氢气.研究证明,某些金属具有很强的捕捉氢的能力,在一定的温度和压力条件下,这些金属能够大量“吸收”氢气,反应生成金属氢化物,同时放出热量.其后,将这些金属氢化物加热,它们又会分解,将储存在其中的氢释放出来.这些会“吸收”氢气的金属,称为储氢合金.则下列说法中不正确的是(  )
A.
氢气在储存过程中主要发生了物理变化
B.
氢能源是未来理想的能源
C.
氢气在使用过程中无污染
D.
氢气在储存过程中主要发生了化学变化
【单选题】近年来,一种新型简便的储氢方法应运而生,即利用储氢合金(金属氢化物)来储存氢气。研究证明,某些金属具有很强的捕捉氢的能力,在一定的温度和压力条件下,这些金属能够大量“吸收”氢气,反应生成金属氢化物,同时放出热量。其后,将这些金属氢化物加热,它们又会分解,将储存在其中的氢释放出来。这些会“吸收”氢气的金属,称为储氢合金。则下列说法中不正确的是()
A.
氢气在储存过程中主要发生了物理变化
B.
氢能源是未来理想的能源
C.
氢气在储存过程中化学能部分转化为内能
D.
氢气在储存过程中主要发生了化学变化
【单选题】骨折急救时,下列与固定的目的无关的一项是
A.
有利于复位
B.
减轻疼痛
C.
防止休克
D.
避免再损伤
E.
便于搬运
【简答题】氢气的储存方法有 、 和 。
相关题目: