这是我得到的错误,但我没有得到任何快速修复如何修复它。它只是给我错误。我是一个修复Android应用程序错误的新手。
抛出错误的代码:
Toast.makeText(CameraPreview2.this, "Cancelled!", Toast.LENGTH_LONG).show();
错误:
The method makeText(Context, CharSequence, int) in the type Toast is not
applicable for the arguments (CameraPreview2<detailLayout>, String, int)
完整的代码是:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
uriVideo = data.getData();
Toast.makeText(CameraPreview2.this, uriVideo.getPath(),
Toast.LENGTH_LONG).show();
}
} else if (resultCode == RESULT_CANCELED) {
uriVideo = null;
Toast.makeText(CameraPreview2.this, "Cancelled!", Toast.LENGTH_LONG)
.show();
...
答案 0 :(得分:0)
无法用您发布的一小段代码说出来但Toast.makeText(...)
确实需要Context
(通常类似于this
或ClassName.this
。)我是不确定你传递了什么,但显然它不是一个上下文。