java - Android/MySQL:如何根据 MySQL 的值检查单选按钮
问题描述
目前,根据我上面的问题,我遇到了麻烦。我在一个单选组中有两个单选按钮。第一个单选按钮是“已批准”,第二个单选按钮是“拒绝”。例如,如果我单击单选按钮“已批准”,则该选中单选按钮的值将保存到 MySQL。然后,如果我想显示单选按钮的值,单选按钮“已批准”如何显示为已检查?(不想显示为 TextView)。
下面是关于如何从编辑文本到文本视图中获取所有值的代码。
此代码从数据库中检索并显示为 textView。
etName = findViewById(R.id.etName);
etBadgeID = findViewById(R.id.etBadgeID);
etDepartment = findViewById(R.id.etDepartment);
etFactory = findViewById(R.id.etFactory);
etPosition = findViewById(R.id.etPosition);
etReviewer = findViewById(R.id.etReviewer);
etTitle = findViewById(R.id.etTitle);
etMonth = findViewById(R.id.etMonth);
etYear = findViewById(R.id.etYear);
etSuggestwill = findViewById(R.id.etSuggestwill);
etPresent = findViewById(R.id.etPresent);
etDetails = findViewById(R.id.etDetails);
etBenefit = findViewById(R.id.etBenefit);
imgAttach = findViewById(R.id.imgAttach);
rgStatus = findViewById(R.id.rgStatus);
etComment = findViewById(R.id.etComment);
Intent intent = getIntent();
User user = (User) intent.getSerializableExtra("user");
etName.setText(user.getName());
etBadgeID.setText(user.getBadgeid());
etDepartment.setText(user.getDepartment());
etFactory.setText(user.getFactory());
etPosition.setText(user.getPosition());
etReviewer.setText(user.getReviewer());
etTitle.setText(user.getTitle());
etMonth.setText(user.getMonth());
etYear.setText(user.getYear());
etSuggestwill.setText(user.getSuggestionwill());
etPresent.setText(user.getPresent());
etDetails.setText(user.getDetails());
etBenefit.setText(user.getBenefit());
imgAttach.setImageBitmap(base64ToBitmap(user.getPhoto()));
etComment.setText(user.getComment());
这就是我在数据库中存储值单选按钮的方式(在提交按钮处)
int selectedId = rgStatus.getCheckedRadioButtonId();
radioButton = findViewById(selectedId);
final String status = radioButton.getText().toString();
update(status);
更新方法(状态)
private void update(final String status){
class updateClass extends AsyncTask<String,Void,String> {
private ProgressDialog loading;
@Override
protected void onPreExecute() {
super.onPreExecute();
loading =
ProgressDialog.show(NeedApproval.this,"Updating.....",null,true,true);
}
@Override
protected void onPostExecute(String s) {
super.onPostExecute(s);
loading.dismiss();
}
@Override
protected String doInBackground(String... params) {
//creating request handler object
RequestHandler requestHandler = new RequestHandler();
//creating request parameters
HashMap<String, String> data = new HashMap<>();
data.put("status",params[0]);
//returing the response
return requestHandler.sendPostRequest(URLs.URL_UPDATE, data);
}
}
updateClass ulc = new updateClass();
ulc.execute(status);
}
解决方案
推荐阅读
- python - 制作均匀形状的张量列表
- c# - 如何将 OneLogin SSO 实施到我的 MVC 网站,类似于 ClassLink SSO 的工作方式
- python - 在 codechef 为什么我的 python 代码给出 NZEC 错误:-
- python - 如何在 TensorFlow 2 中恢复 tf.data.Dataset 位置(状态)
- css - 文字的角度,使其在图像上看起来更自然
- javascript - 在页面上的所有段落或其他元素中显示类名
- c++ - 如何在 C++ 中优雅地对待位掩码?
- java - 如何多次使用按钮?
- css - 在 mobil 中将表格方向更改为垂直模式
- android - 颤振 - 如何为文本的一部分着色(即在句子中间)