Good afternoon, I wrote a program that when you click on the onClickButton button, it displays a text field in which you can write text using the virtual keyboard, but when the text is written when you click on the OK button to apply it, nothing happens. You have to manually remove the keyboard and to apply the written text you need to press the onClickButton button again.
public void onClickButton(View view) { if(TextUtils.isEmpty(informationAboutFile)){//Π΅ΡΠ»ΠΈ informationAboutFile ΡΠΎΠ΄Π΅ΡΠΆΠΈΡ Π½ΠΎΠ»Ρ mAutoComplete.setVisibility(AutoCompleteTextView.VISIBLE); } informationAboutFile = mAutoComplete.getText().toString();// ΠΈΠ½ΡΡ Ρ mAutoComplete ΠΏΠΎΠΌΠ΅ΡΠ°Π΅ΠΌ Π² informationAboutFile if (flag == true){ if (!TextUtils.isEmpty(informationAboutFile)) {//Π΅ΡΠ»ΠΈ informationAboutFile Π½Π΅ ΠΏΡΡΡΠΎΠΉ mAutoComplete.setVisibility(AutoCompleteTextView.INVISIBLE); try { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);// ΠΠ°ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ Π΄Π»Ρ Π·Π°ΠΏΡΡΠΊΠ° ΠΊΠ°ΠΌΠ΅ΡΡ intent.putExtra(MediaStore.EXTRA_OUTPUT, generateFileUri(TYPE_PHOTO)); startActivityForResult(intent, TAKE_PICTURE);// ΠΠ°ΠΌΠ΅ΡΠ΅Π½ΠΈΠ΅ Π΄Π»Ρ Π·Π°ΠΏΡΡΠΊΠ° ΠΊΠ°ΠΌΠ΅ΡΡ } catch (ActivityNotFoundException e) { // ΠΡΠ²ΠΎΠ΄ΠΈΠΌ ΡΠΎΠΎΠ±ΡΠ΅Π½ΠΈΠ΅ ΠΎΠ± ΠΎΡΠΈΠ±ΠΊΠ΅ Toast toast1 = Toast.makeText(getApplicationContext(), R.string.message2, Toast.LENGTH_LONG); toast1.setGravity(Gravity.CENTER, 0, 0); toast1.show(); } } } }
I try to do so, that is, assign the variable flag = true and, in the response, perform actions but there is no result.
public boolean onKeyDown (int keyCode, KeyEvent event){ if (keyCode == KeyEvent.KEYCODE_ENTER) { // ΠΎΠ±ΡΠ°Π±Π°ΡΡΠ²Π°Π΅ΠΌ Π½Π°ΠΆΠ°ΡΠΈΠ΅ ΠΊΠ½ΠΎΠΏΠΊΠΈ DONE flag = true; return true; } return false; }/**/
AutoCom....VISIBLEif you can justView.VISIBLE- Flippy