0

这是我得到的错误,但我没有得到任何关于如何修复它的快速修复。它只是给了我错误。我是修复 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();
    ...
4

1 回答 1

0

不可能用你发布的一点代码说但Toast.makeText(...)确实需要一个Context(通常类似于thisor ClassName.this。)我不确定你传递了什么,但显然它不是上下文。

于 2012-12-31T14:58:00.527 回答