I had a problem that I had never had before almost three years of development with Android ...
I want to take a picture, and after the image is recorded, the EditText activity will become clear. What I'm doing is setting the values ββof EditText - Strings , using getText().toString() to restore them after shooting.
Strings are perfectly saved with data, but when I use setText , it does not work ... It is strange that setHint works!
How can it be?
Here is the code I'm using:
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE) { if (resultCode == RESULT_OK) { // Image captured and saved to fileUri specified in the Intent grabImage(imgView); for (int u = 0; u <= 2; u++) { if (savedImgs[u].equals("")) { imgs = u + 1; savedImgs[u] = photo.toString(); break; } } /*Bitmap thumbnail = (Bitmap) data.getExtras().get("data"); ---> It is a small bitmap, for icons... imgView.setImageBitmap(thumbnail); imgView.setVisibility(View.VISIBLE);*/ } else if (resultCode == RESULT_CANCELED) { // User cancelled the image capture } else { Toast.makeText(this, "Image couldn't be taken. Try again later.", Toast.LENGTH_LONG).show(); } } if (!tempSpotName.equals("") || !tempSpotDesc.equals("")) { name.setText(tempSpotName); description.setText(tempSpotDesc); } }
name and description are global EditTexts and tempSpotName and tempSpotDesc are global Strings .
How to set the text?
source share