java-无法解析R符号和方法

java-无法解析R符号和方法,第1张

概述该项目以前是在eclipse中构建的,并且能够顺利运行.现在,我已将其导入androidstudio中,这给了我一些错误.我试图为我的项目清理,重建,使缓存无效/重新启动并与Gradle文件同步.但是,这些都不对我有用.我的MainActivity.java中的代码“cropImageView.getEdge()”和“cropImageView.

该项目以前是在eclipse中构建的,并且能够顺利运行.现在,我已将其导入android studio中,这给了我一些错误.我试图为我的项目清理,重建,使缓存无效/重新启动并与Gradle文件同步.但是,这些都不对我有用.我的MainActivity.java中的代码“ cropImageVIEw.getEdge()”和“ cropImageVIEw.getCircleData()”也出现了错误.我不确定裁纸器库是否有问题.有人知道哪里出问题了吗?

This is the error I have gotten

我的MainActivity.java:

public class MainActivity extends AppCompatActivity {static Uri outPutfileUri;public String filepath = "";public static CropImageVIEw cropImageVIEw;public static final int CAMERA_IMAGE =2;public static final int galLERY_CHOOSER_INTENT = 3;public static final int galLERY_KITKAT_INTENT_CALLED= 4;public static Bitmap activeBmp;public static Bitmap originalBmp;private static final int DEFAulT_ASPECT_RATIO_VALUES = 10;private static final String ASPECT_RATIO_X = "ASPECT_RATIO_X";private static final String ASPECT_RATIO_Y = "ASPECT_RATIO_Y";private int mAspectRatioX = DEFAulT_ASPECT_RATIO_VALUES;private int mAspectRatioY = DEFAulT_ASPECT_RATIO_VALUES;ImageVIEw croppedImageVIEw;file file;Imagebutton btimage,btCrop,btProceed;CropPingInstructionDlg dialog;CheckBox cb_savePreferencedialog;public static final String Save_CheckBoxSettingdialog = "MyCheckBoxSettingdialogforcropPingactivity";boolean checkedCheckBoxdialog=false;Bitmap croppedImage;boolean cropped=false;// this is very important to use the navtive opencv's library     static {            if (!OpenCVLoader.initDeBUG()) {                // Handle initialization error                Log.d("ERROR", "Unable to load OpenCV");            }            else            {                Log.d("SUCCESS", "OpenCV loaded");            }        }@OverrIDeprotected voID onRestoreInstanceState(Bundle bundle) {    super.onRestoreInstanceState(bundle);    mAspectRatioX = bundle.getInt(ASPECT_RATIO_X);    mAspectRatioY = bundle.getInt(ASPECT_RATIO_Y);}    protected voID onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentVIEw(R.layout.activity_main);        final SharedPreferences sp = getSharedPreferences("activitIEs", MODE_PRIVATE);        dialog = new CropPingInstructionDlg(MainActivity.this);        cb_savePreferencedialog = (CheckBox)dialog.findVIEwByID(R.ID.cb_savePreferencedialog);         SharedPreferences prefEditdialog = getSharedPreferences(Save_CheckBoxSettingdialog, MODE_PRIVATE);             if(prefEditdialog.contains("CheckBoxValueDialog1")){                cb_savePreferencedialog.setChecked(true);            }            else            {                openDialoginstruction();            }        cropImageVIEw = (CropImageVIEw) findVIEwByID(R.ID.CropImageVIEw);        croppedImageVIEw = (ImageVIEw) findVIEwByID(R.ID.croppedImageVIEw);        cropImageVIEw.setVisibility(VIEw.GONE);        croppedImageVIEw.setVisibility(VIEw.GONE);        btimage=(Imagebutton) findVIEwByID(R.ID.btimage);        btimage.setonClickListener(new OnClickListener() {            public voID onClick(VIEw v) {                List<String> data= new ArrayList<String>();                data.add("import from local device.");                data.add("Take camera image.");                AdapterGetimage adapter = new AdapterGetimage(MainActivity.this);                adapter.setData(data);                new AlertDialog.Builder(MainActivity.this).setAdapter(adapter, new DialogInterface.OnClickListener() {                    @OverrIDe                    public voID onClick(DialogInterface dialog, int which) {                     //Todo - Code when List item is clicked (int which - is param that gives you the index of clicked item)                        if (which==0) {                            getFromgallery();                        }                        if(which==1)                        {                            getimageFromCamera();                        }                    }                })               .setNegativebutton("Cancel", new DialogInterface.OnClickListener() {                    @OverrIDe                    public voID onClick(DialogInterface dialog, int which) {                    }                })                .setCancelable(false)                .show();              }        });        btCrop=(Imagebutton) findVIEwByID(R.ID.btCrop);        btCrop.setonClickListener(new OnClickListener() {            public voID onClick(VIEw v) {                if(cropImageVIEw.getVisibility() == VIEw.VISIBLE){                    croppedImage = cropImageVIEw.getCroppedImage();                    //size test                    // croppedImage = croppedImage.createScaledBitmap(croppedImage, activeBmp.getWIDth(), ((activeBmp.getWIDth() * activeBmp.getHeight()) / activeBmp.getWIDth()), true);                    croppedImageVIEw.setVisibility(VIEw.VISIBLE);                    croppedImageVIEw.setimageBitmap(croppedImage);                    activeBmp = croppedImage;                    globalVar.edgeData= cropImageVIEw.getEdge();                    globalVar.gatheredData= cropImageVIEw.getCircleData();                    cropped=true;                    }                    else                    {                        Toast.makeText(MainActivity.this, "Please select your desired image before using the cropPing function.", Toast.LENGTH_LONG).show();                    }              }        });        btProceed = (Imagebutton)findVIEwByID(R.ID.btProceed);        btProceed.setonClickListener(new OnClickListener() {            @OverrIDe            public voID onClick(VIEw arg0) {                // Todo auto-generated method stub                if(cropImageVIEw.getVisibility() == VIEw.VISIBLE){                    if(cropped)                    {                    try {                        InternalStorage.writeBitmap(MainActivity.this,"image", activeBmp);                        InternalStorage.writeBitmap(MainActivity.this,"originalimage", originalBmp);                        Intent intent = new Intent(MainActivity.this, EditimageActivity.class);                        startActivity(intent);                    } catch (IOException e) {                        // Todo auto-generated catch block                        e.printstacktrace();                    }                    }                    else                    {                        Toast.makeText(MainActivity.this, "Please crop your desired image before proceeding to the next step.", Toast.LENGTH_LONG).show();                    }                }                else                {                    Toast.makeText(MainActivity.this, "Please select your desired image before proceeding to the next step.", Toast.LENGTH_LONG).show();                }            }        });        if (savedInstanceState != null) {            // String savedText = savedInstanceState.getString(KEY_TEXT_VALUE);            if (!savedInstanceState.getString("filepath").equals("")) {                filepath = savedInstanceState.getString("filepath");                // mTextVIEw.setText(savedText);                LoadPicture(filepath);                    croppedImageVIEw.setimageBitmap(globalVar.CroppedImage);                croppedImageVIEw.setVisibility(VIEw.VISIBLE);                cropImageVIEw.setVisibility(VIEw.VISIBLE);            }        }    }protected voID onSaveInstanceState(Bundle bundle) {    super.onSaveInstanceState(bundle);    bundle.putInt(ASPECT_RATIO_X, mAspectRatioX);    bundle.putInt(ASPECT_RATIO_Y, mAspectRatioY);    // if (!filepath.equals("")) {    if (filepath != null) {        bundle.putString("filepath", filepath);    } else {        bundle.putString("filepath", "");    }    if(cropped==true)    {        globalVar.CroppedImage= Bitmap.createBitmap(croppedImage);    }}@OverrIDepublic boolean onCreateOptionsMenu(Menu menu) {    // Inflate the menu; this adds items to the action bar if it is present.    getMenuInflater().inflate(R.menu.main, menu);    return true;}@OverrIDepublic boolean onoptionsItemSelected(MenuItem item) {    // Handle action bar item clicks here. The action bar will    // automatically handle clicks on the Home/Up button, so long    // as you specify a parent activity in AndroIDManifest.xml.     int ID = item.getItemID();    if(ID == R.ID.About_Us)    {        openDialog();    }    return super.onoptionsItemSelected(item);}//cf code here@RequiresAPI(API = Build.VERSION_CODES.KITKAT)@OverrIDeprotected voID onActivityResult(int requestCode, int resultCode, Intent data) {    // Todo auto-generated method stub    super.onActivityResult(requestCode, resultCode, data);    try {        if (requestCode == galLERY_CHOOSER_INTENT) {            if (null == data) return;            String selectedImagePath;            Uri selectedImageUri = data.getData();            //MEDIA galLERY            selectedImagePath = ImagefilePath.getPath(getApplicationContext(), selectedImageUri);            cropImageVIEw.requestLayout();            LoadPicture(selectedImagePath);            cropImageVIEw.setVisibility(VIEw.VISIBLE);        }          if(requestCode ==CAMERA_IMAGE)            {                if (resultCode == Activity.RESulT_OK) {                    cropImageVIEw.requestLayout();                    // if(!filepath.equals(""))                    if (outPutfileUri.toString() != null) {                          this.filepath=outPutfileUri.getPath();                        LoadPicture(outPutfileUri.getPath());                        cropImageVIEw.setVisibility(VIEw.VISIBLE);                    }             }            }    } catch (Throwable ex) {        //Toast.makeText(MainActivity.this, ex.toString(), Toast.LENGTH_LONG).show();    }}public String getgalleryImagePath(Intent data) {    try {        Uri imguri = data.getData();        String filePath = "";        if (data.getType() == null) {            // For getting images from default gallery app.            String[] filePathColumn = { MediaStore.Images.Media.DATA };            Cursor cursor = getContentResolver().query(imguri,                    filePathColumn, null, null, null);            cursor.movetoFirst();            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);            filePath = cursor.getString(columnIndex);            cursor.close();        } else if (data.getType().equals("image/jpeg")                || data.getType().equals("image/png")) {            filePath = imguri.getPath();        }        return filePath;    } catch (Exception e) {        return null;    }}private String getPath(Uri uri) {    if( uri == null ) {        return null;    }    String[] projection = { MediaStore.Images.Media.DATA };    Cursor cursor;    if(Build.VERSION.SDK_INT >19)    {        // Will return "image:x*"        String wholeID = documentsContract.getdocumentID(uri);        // Split at colon, use second item in the array        String ID = wholeID.split(":")[1];        // where ID is equal to                     String sel = MediaStore.Images.Media._ID + "=?";        cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,                                       projection, sel, new String[]{ ID }, null);    }    else    {        cursor = getContentResolver().query(uri, projection, null, null, null);    }    String path = null;    try    {        int column_index = cursor        .getColumnIndex(MediaStore.Images.Media.DATA);        cursor.movetoFirst();        path = cursor.getString(column_index).toString();        cursor.close();    }    catch(NullPointerException e) {    }    return path;}public String getCameraimagePath(Intent data) {    try {        Uri imguri = data.getData();        String filePath = "";        if (data.getType() == null) {            // For getting images from default gallery app.            String[] filePathColumn = { MediaStore.Images.Media.DATA };            Cursor cursor = getContentResolver().query(imguri,                    filePathColumn, null, null, null);            cursor.movetoFirst();            int columnIndex = cursor.getColumnIndex(filePathColumn[0]);            filePath = cursor.getString(columnIndex);            cursor.close();        } else if (data.getType().equals("image/jpeg")                || data.getType().equals("image/png")) {            filePath = imguri.getPath();        }        return filePath;    } catch (Exception e) {        return null;    }}public voID LoadPicture(String filepath) {    if (!new file(filepath).exists()) {        Toast.makeText(this, "Image does not exist.", Toast.LENGTH_SHORT)                .show();    } else {        display display = getwindowManager().getDefaultdisplay();        Point size = new Point();        display.getSize(size);        int screenwIDth = size.x;        int screenheight = size.y;        int picwIDth = 0;        if(screenwIDth < screenheight)        {            picwIDth = screenwIDth;        }        else        {            picwIDth = screenheight;        }        picwIDth = (int) (0.8 * picwIDth);        Bitmap img = decodeSampledBitmapFromresource(filepath, picwIDth);        if (img.getWIDth() < img.getHeight()) {            Bitmap rotatedbmp = RotateBitmap(img, 90);            img = rotatedbmp;        } else {            ;        }        if (img.getWIDth() > img.getHeight()) {            if (img.getWIDth() > picwIDth) {                cropImageVIEw.getLayoutParams().height = picwIDth                        * img.getHeight() / img.getWIDth();                cropImageVIEw.getLayoutParams().wIDth = picwIDth;                img = Bitmap.createScaledBitmap(img, picwIDth,                        ((picwIDth * img.getHeight()) / img.getWIDth()), true);            } else {                cropImageVIEw.getLayoutParams().wIDth = img.getWIDth();                cropImageVIEw.getLayoutParams().height = img.getHeight();            }        } else if (img.getHeight() > img.getWIDth()) {            if (img.getHeight() > picwIDth) {                cropImageVIEw.getLayoutParams().height = picwIDth;                cropImageVIEw.getLayoutParams().wIDth = picwIDth                        * img.getWIDth() / img.getHeight();                img = Bitmap.createScaledBitmap(img,                        ((picwIDth * img.getWIDth()) / img.getHeight()), picwIDth,                        true);            } else {                cropImageVIEw.getLayoutParams().wIDth = img.getWIDth();                cropImageVIEw.getLayoutParams().height = img.getHeight();            }        } else {// same square image            if (img.getWIDth() > picwIDth) {                cropImageVIEw.getLayoutParams().height = picwIDth;                cropImageVIEw.getLayoutParams().wIDth = picwIDth;                img = Bitmap.createScaledBitmap(img, picwIDth, picwIDth, true);            } else {                cropImageVIEw.getLayoutParams().wIDth = img.getWIDth();                cropImageVIEw.getLayoutParams().height = img.getHeight();            }        }        activeBmp = null;        activeBmp = img.copy(Bitmap.Config.ARGB_8888, true);        originalBmp=img.copy(Bitmap.Config.ARGB_8888, true);        //cropImageVIEw.getLayoutParams().height = activeBmp.getHeight();        //cropImageVIEw.getLayoutParams().wIDth = activeBmp.getWIDth();        cropImageVIEw.setimageBitmap(activeBmp);        //croppedImageVIEw.setimageBitmap(activeBmp);        img.recycle();    }//else ends}public static Bitmap decodeSampledBitmapFromresource(String filepath,int reqWIDth) {    // First decode with inJustDecodeBounds=true to check dimensions    final BitmapFactory.Options options = new BitmapFactory.Options();    options.inJustDecodeBounds = true;    BitmapFactory.decodefile(filepath, options);    // Calculate inSampleSize    options.inSampleSize = calculateInSampleSize(options, reqWIDth);    // Decode bitmap with inSampleSize set    options.inJustDecodeBounds = false;    return BitmapFactory.decodefile(filepath, options);}public static Bitmap RotateBitmap(Bitmap source, float angle) {    Matrix matrix = new Matrix();    matrix.postRotate(angle);    return Bitmap.createBitmap(source, 0, 0, source.getWIDth(),            source.getHeight(), matrix, true);}public static int calculateInSampleSize(BitmapFactory.Options options,        int reqWIDth) {    // Raw height and wIDth of image    final int height = options.outHeight;    final int wIDth = options.outWIDth;    int inSampleSize = 1;    // if (height > reqHeight || wIDth > reqWIDth) {    if (wIDth > reqWIDth) {        // final int halfheight = height / 2;        final int halfWIDth = wIDth / 2;        // Calculate the largest inSampleSize value that is a power of 2 and        // keeps both        // height and wIDth larger than the requested height and wIDth.        // while ((halfheight / inSampleSize) > reqHeight        // && (halfWIDth / inSampleSize) > reqWIDth) {        while ((halfWIDth / inSampleSize) > reqWIDth) {            inSampleSize *= 2;        }    }    return inSampleSize;}public voID openDialog() {    final AboutUsDlg dialog = new AboutUsDlg(this); // context, this etc.    dialog.setTitle("About Us");    button btnClose = (button) dialog.findVIEwByID(R.ID.btOk);    btnClose.setonClickListener(new VIEw.OnClickListener() {        @OverrIDe        public voID onClick(VIEw v) {            dialog.dismiss();        }    });    dialog.show();} public voID getFromgallery(){    //cf code     /*     if (Build.VERSION.SDK_INT <23){        final Intent intent = new Intent();        intent.setType("image/*");        intent.setAction(Intent.ACTION_GET_CONTENT);        startActivityForResult(intent, galLERY_CHOOSER_INTENT);    } else {        Intent intent = new Intent(Intent.ACTION_OPEN_document);        intent.addcategory(Intent.category_OPENABLE);        intent.setType("image/*");        startActivityForResult(intent, galLERY_KITKAT_INTENT_CALLED);    }    */     final Intent intent = new Intent();        intent.setType("image/*");        intent.setAction(Intent.ACTION_GET_CONTENT);        startActivityForResult(Intent.createChooser(intent, "Select file"),galLERY_CHOOSER_INTENT);    //final Intent intent = new Intent();    //intent.setType("image/*");    //intent.setAction(Intent.ACTION_GET_CONTENT);    //startActivityForResult(intent, galLERY_CHOOSER_INTENT);}public voID getimageFromCamera(){    Intent intent= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);    file = new file(Environment.getExternalStorageDirectory(),            "APDColonyImage.jpg");    globalVar.Cameraimage=file;            outPutfileUri = Uri.fromfile(file);            intent.putExtra(MediaStore.EXTRA_OUTPUT, outPutfileUri);            startActivityForResult(intent, CAMERA_IMAGE);} public voID openDialoginstruction() {      cb_savePreferencedialog.setonClickListener(new OnClickListener() {          @OverrIDe          public voID onClick(VIEw v) {                    //is chkIos checked?            if (((CheckBox) v).isChecked()) {                checkedCheckBoxdialog=true;            }            else             {                checkedCheckBoxdialog=false;            }          }        });        button btnClose = (button) dialog.findVIEwByID(R.ID.btOk);        btnClose.setonClickListener(new VIEw.OnClickListener() {            @OverrIDe            public voID onClick(VIEw v) {                if(checkedCheckBoxdialog==true){                     SharedPreferences.Editor CheckBoxEditor = getSharedPreferences(Save_CheckBoxSettingdialog, MODE_PRIVATE).edit();                     CheckBoxEditor.putBoolean("CheckBoxValueDialog1", checkedCheckBoxdialog);                     CheckBoxEditor.commit();                }                else                {                    SharedPreferences.Editor CheckBoxEditor = getSharedPreferences(Save_CheckBoxSettingdialog, MODE_PRIVATE).edit();                    CheckBoxEditor.clear();                    CheckBoxEditor.commit();                }                dialog.dismiss();            }        });        dialog.show();    } public boolean onKeyDown(int keyCode, KeyEvent event) {        // cleanup app, save preferences, etc.     exitApplication() ;        // finish(); // not working properly, especially not with asynchronous tasks running        // return moveTaskToBack(true);        return super.onKeyDown(keyCode, event);    } public voID exitApplication() {        AlertDialog.Builder builder = new AlertDialog.Builder(this);        builder.setTitle("Are you sure you want to exit?")                // Write the code below                .setPositivebutton("Yes",                        new DialogInterface.OnClickListener() {                            @OverrIDe                            public voID onClick(DialogInterface dialog, int ID) {                                finish();                            }                        })                .setNegativebutton("No", new DialogInterface.OnClickListener() {                    public voID onClick(DialogInterface dialog, int ID) {                    }                });        AlertDialog alertDialog = builder.create();        alertDialog.show();    }

我的activity_main.xml:

<relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"xmlns:tools="http://schemas.androID.com/tools"androID:layout_wIDth="match_parent"androID:layout_height="match_parent"tools:context=".MainActivity"><ScrollVIEw    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent"     androID:orIEntation="vertical"     >    <linearLayout        androID:layout_wIDth="match_parent"        androID:layout_height="wrap_content"        androID:orIEntation="vertical" >          <linearLayout            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center"            androID:orIEntation="horizontal"            androID:weightSum="3" >            <Imagebutton                androID:ID="@+ID/btimage"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_toleftOf="@+ID/btCrop"                androID:layout_weight="1"                androID:adjustVIEwBounds="true"                androID:scaleType="fitCenter"                androID:src="@drawable/getimage_icon9" />            <Imagebutton                androID:ID="@+ID/btCrop"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_centerInParent="true"                androID:layout_weight="1"                androID:adjustVIEwBounds="true"                androID:scaleType="fitCenter"                androID:src="@drawable/crop_icon9" />            <Imagebutton                androID:ID="@+ID/btProceed"                androID:layout_wIDth="wrap_content"                androID:layout_height="wrap_content"                androID:layout_toRightOf="@+ID/btCrop"                androID:layout_weight="1"                androID:adjustVIEwBounds="true"                androID:scaleType="fitCenter"                androID:src="@drawable/next_icon9" />        </linearLayout>        <TextVIEw            androID:ID="@+ID/tvCrop1"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center"            androID:text="@string/Image"            androID:textAppearance="?androID:attr/textAppearanceLarge" />        <!--        <com.edmodo.cropper.CropImageVIEw            xmlns:custom="http://schemas.androID.com/apk/res-auto"            androID:ID="@+ID/CropImageVIEw"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center_horizontal" />        -->        <com.edmodo.cropper.CropImageVIEw            xmlns:custom="http://schemas.androID.com/apk/res-auto"            androID:ID="@+ID/CropImageVIEw"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center"            custom:imageResource="@drawable/emptyimage"/>        <TextVIEw            androID:ID="@+ID/tvCrop2"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center"            androID:text="@string/Cropped_image"            androID:textAppearance="?androID:attr/textAppearanceLarge" />        <ImageVIEw            androID:ID="@+ID/croppedImageVIEw"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            androID:layout_gravity="center"            androID:adjustVIEwBounds="true"            androID:scaleType="fitCenter"            androID:src="@drawable/emptyimage"            tools:ignore="ContentDescription" />    </linearLayout></ScrollVIEw>

解决方法:

只需清理构建并重新运行项目即可.它会自动解决问题

总结

以上是内存溢出为你收集整理的java-无法解析R符号和方法全部内容,希望文章能够帮你解决java-无法解析R符号和方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1081170.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存