В настоящее время у меня возникли проблемы, связанные с моим вопросом выше. У меня две радиокнопки в одной радиогруппе. Первая радиокнопка «Одобрено», а вторая радиокнопка «Отклонено». Например, если я щелкнул переключатель «Утверждено», значение этого переключателя будет сохранено в 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());
Вот так я могу сохранить переключатель значения в базе данных (в кнопке Submit)
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);
}