KrL*_*ler 6 android settext android-edittext
我有一个问题,这是我用Android开发近三年来从未有过的问题...
我想拍照,拍完照片后,EditText活动的s变得清晰.我在做什么设置的值EditText,以Strings使用getText().toString()拍照后恢复它们.
字符串与数据完美地存储在一起,但是当我使用时setText,它不起作用......奇怪的是它setHint有效!
怎么会这样?
这是我正在使用的代码:
@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);
}
}
Run Code Online (Sandbox Code Playgroud)
name并且description是全球性的EditTexts,tempSpotName并且tempSpotDesc是全球性的Strings.
我该如何设置文字?
Jay*_*aya 10
有些时候,改变edittext的onactivity结果是行不通的。我也面临同样的问题
而不是设置
edittext.settext("yourtext");
Run Code Online (Sandbox Code Playgroud)
更改为跟随 onactivityresult
edittext.post(new Runnable(){
edittext.settext("yourtext");
});
Run Code Online (Sandbox Code Playgroud)
它对我有用。
| 归档时间: |
|
| 查看次数: |
8508 次 |
| 最近记录: |