当前位置: 首页 > 知识库问答 >
问题:

FingerPaintActive(对象类型的方法未定义)

柯甫
2023-03-14
package com.example.chart;

import java.io.File;    
import java.io.FileOutputStream;    
import android.support.v7.app.ActionBarActivity;    
import android.app.AlertDialog;    
import android.content.Context;    
import android.content.DialogInterface;    
import android.graphics.Bitmap;    
import android.graphics.Bitmap.CompressFormat;    
import android.graphics.BlurMaskFilter;    
import android.graphics.Canvas;        
import android.graphics.EmbossMaskFilter;   
import android.graphics.MaskFilter;         
import android.graphics.Paint;    
import android.graphics.Path;    
import android.graphics.PorterDuff;    
import android.graphics.PorterDuffXfermode;    
import android.os.Bundle;    
import android.os.Environment;    
import android.view.Menu;    
import android.view.MenuItem;    
import android.view.MotionEvent;     
import android.view.View;     
import android.widget.EditText;     
import android.widget.LinearLayout;                   

public class FingerPaintActivity  implements ColorPickerDialog.OnColorChangedListener  {       
    MyView mv;            
    AlertDialog dialog;         
    @Override                  
    protected void onCreate(Bundle savedInstanceState) {         
    super.onCreate(savedInstanceState);                

    mv= new MyView(FingerPaintActivity.this);                   
    mv.setDrawingCacheEnabled(true);                      
    mv.setBackgroundResource(R.drawable.ic_launcher);//set the back ground if you wish to                  
    setContentView(mv);       
    mPaint = new Paint();       
    mPaint.setAntiAlias(true);     
    mPaint.setDither(true);       
    mPaint.setColor(0xFFFF0000);        
    mPaint.setStyle(Paint.Style.STROKE);       
    mPaint.setStrokeJoin(Paint.Join.ROUND);      
    mPaint.setStrokeCap(Paint.Cap.ROUND);       
    mPaint.setStrokeWidth(20);         
    mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },       
                               0.4f, 6, 3.5f);         
    mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);         
    }

    private Paint       mPaint;            
    private MaskFilter  mEmboss;            
    private MaskFilter  mBlur;                  

    public void colorChanged(int color) {     
    mPaint.setColor(color);
    }

    public class MyView extends View {

    private static final float MINP = 0.25f;
    private static final float MAXP = 0.75f;
    private Bitmap  mBitmap;
    private Canvas  mCanvas;
    private Path    mPath;
    private Paint   mBitmapPaint;
    Context context;

    public MyView(Context c) {
    super(c);
    context=c;
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);   

    }

    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    mCanvas = new Canvas(mBitmap);

    }

    protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);


    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

    canvas.drawPath(mPath, mPaint);
    }

    private float mX, mY;
    private static final float TOUCH_TOLERANCE = 4;

    private void touch_start(float x, float y) {
    //showDialog(); 
    mPath.reset();
    mPath.moveTo(x, y);
    mX = x;
    mY = y;

    }
    private void touch_move(float x, float y) {
    float dx = Math.abs(x - mX);
    float dy = Math.abs(y - mY);
    if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);
        mX = x;
        mY = y;
    }
    }
    private void touch_up() {
    mPath.lineTo(mX, mY);
    // commit the path to our offscreen
    mCanvas.drawPath(mPath, mPaint);
    // kill this so we don't double draw
    mPath.reset();

    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN));
    //mPaint.setMaskFilter(null);
    }

    public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            touch_start(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE:

            touch_move(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP:
            touch_up();
            invalidate();
            break;
    }
    return true;
    }  
    }

    private static final int COLOR_MENU_ID = Menu.FIRST;
    private static final int EMBOSS_MENU_ID = Menu.FIRST + 1;
    private static final int BLUR_MENU_ID = Menu.FIRST + 2;
    private static final int ERASE_MENU_ID = Menu.FIRST + 3;
    private static final int SRCATOP_MENU_ID = Menu.FIRST + 4;
    private static final int Save = Menu.FIRST + 5;

    public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    menu.add(0, COLOR_MENU_ID, 0, "Color").setShortcut('3', 'c');
    menu.add(0, EMBOSS_MENU_ID, 0, "Emboss").setShortcut('4', 's');
    menu.add(0, BLUR_MENU_ID, 0, "Blur").setShortcut('5', 'z');
    menu.add(0, ERASE_MENU_ID, 0, "Erase").setShortcut('5', 'z');
    menu.add(0, SRCATOP_MENU_ID, 0, "SrcATop").setShortcut('5', 'z');
    menu.add(0, Save, 0, "Save").setShortcut('5', 'z');

    return true;
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
     super.onPrepareOptionsMenu(menu);
     return true;
     }

    public boolean onOptionsItemSelected(MenuItem item) {
    mPaint.setXfermode(null);
    mPaint.setAlpha(0xFF);

    switch (item.getItemId()) {
    case COLOR_MENU_ID:
      //  new ColorPickerDialog(this, this, mPaint.getColor()).show();
        new ColorPickerDialog(this, this , mPaint.getColor()).show();
        return true;
    case EMBOSS_MENU_ID:
        if (mPaint.getMaskFilter() != mEmboss) {
            mPaint.setMaskFilter(mEmboss);
        } else {
            mPaint.setMaskFilter(null);
        }
        return true;
    case BLUR_MENU_ID:
        if (mPaint.getMaskFilter() != mBlur) {
            mPaint.setMaskFilter(mBlur);
        } else {
            mPaint.setMaskFilter(null);
        }
        return true;
    case ERASE_MENU_ID:
       mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
       mPaint.setAlpha(0x80);
        return true;
    case SRCATOP_MENU_ID:

        mPaint.setXfermode(new PorterDuffXfermode(
                                            PorterDuff.Mode.SRC_ATOP));
        mPaint.setAlpha(0x80);
        return true;
    case Save:
        AlertDialog.Builder editalert = new AlertDialog.Builder(FingerPaintActivity.this);
            editalert.setTitle("Please Enter the name with which you want to Save");
            final EditText input = new EditText(FingerPaintActivity.this)
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.FILL_PARENT);
            input.setLayoutParams(lp);
            editalert.setView(input);
            editalert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                String name= input.getText().toString();
                Bitmap bitmap = mv.getDrawingCache();

             String path = Environment.getExternalStorageDirectory().getAbsolutePath(); 
                File file = new File("/sdcard/"+name+".png");           
                try 
                {
                    if(!file.exists())
                {
                    file.createNewFile();
                }
                    FileOutputStream ostream = new FileOutputStream(file);
                    bitmap.compress(CompressFormat.PNG, 10, ostream);
                    ostream.close();
                    mv.invalidate();                            
                } 
                catch (Exception e) 
                {
                    e.printStackTrace();
                }finally
                {

                    mv.setDrawingCacheEnabled(false);                           
                }
                }
            });

            editalert.show();       
        return true;    
    }
    return super.onOptionsItemSelected(item);
    }
    }

}                    
**fingure paint Activity**
package com.example.chart;

import java.io.File;
import java.io.FileOutputStream;
import android.support.v7.app.ActionBarActivity;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BlurMaskFilter;
import android.graphics.Canvas;
import android.graphics.EmbossMaskFilter;
import android.graphics.MaskFilter;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.os.Bundle;
import android.os.Environment;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;

public class FingerPaintActivity extends Activity  implements ColorPickerDialog.OnColorChangedListener  {
    MyView mv;
    AlertDialog dialog;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mv= new MyView(FingerPaintActivity.this);
    mv.setDrawingCacheEnabled(true);
    mv.setBackgroundResource(R.drawable.ic_launcher);//set the back ground if you wish to
    setContentView(mv);
    mPaint = new Paint();
    mPaint.setAntiAlias(true);
    mPaint.setDither(true);
    mPaint.setColor(0xFFFF0000);
    mPaint.setStyle(Paint.Style.STROKE);
    mPaint.setStrokeJoin(Paint.Join.ROUND);
    mPaint.setStrokeCap(Paint.Cap.ROUND);
    mPaint.setStrokeWidth(20);
    mEmboss = new EmbossMaskFilter(new float[] { 1, 1, 1 },
                               0.4f, 6, 3.5f);
    mBlur = new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL);
    }

    private Paint       mPaint;
    private MaskFilter  mEmboss;
    private MaskFilter  mBlur;

    public void colorChanged(int color) {
    mPaint.setColor(color);
    }

    public class MyView extends View {

    private static final float MINP = 0.25f;
    private static final float MAXP = 0.75f;
    private Bitmap  mBitmap;
    private Canvas  mCanvas;
    private Path    mPath;
    private Paint   mBitmapPaint;
    Context context;

    public MyView(Context c) {
    super(c);
    context=c;
    mPath = new Path();
    mBitmapPaint = new Paint(Paint.DITHER_FLAG);   

    }

    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    mBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
    mCanvas = new Canvas(mBitmap);

    }

    protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);


    canvas.drawBitmap(mBitmap, 0, 0, mBitmapPaint);

    canvas.drawPath(mPath, mPaint);
    }

    private float mX, mY;
    private static final float TOUCH_TOLERANCE = 4;

    private void touch_start(float x, float y) {
    //showDialog(); 
    mPath.reset();
    mPath.moveTo(x, y);
    mX = x;
    mY = y;

    }
    private void touch_move(float x, float y) {
    float dx = Math.abs(x - mX);
    float dy = Math.abs(y - mY);
    if (dx >= TOUCH_TOLERANCE || dy >= TOUCH_TOLERANCE) {
        mPath.quadTo(mX, mY, (x + mX)/2, (y + mY)/2);
        mX = x;
        mY = y;
    }
    }
    private void touch_up() {
    mPath.lineTo(mX, mY);
    // commit the path to our offscreen
    mCanvas.drawPath(mPath, mPaint);
    // kill this so we don't double draw
    mPath.reset();

    mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN));
    //mPaint.setMaskFilter(null);
    }

    public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();

    switch (event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            touch_start(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_MOVE:

            touch_move(x, y);
            invalidate();
            break;
        case MotionEvent.ACTION_UP:
            touch_up();
            invalidate();
            break;
    }
    return true;
    }  
    }

    private static final int COLOR_MENU_ID = Menu.FIRST;
    private static final int EMBOSS_MENU_ID = Menu.FIRST + 1;
    private static final int BLUR_MENU_ID = Menu.FIRST + 2;
    private static final int ERASE_MENU_ID = Menu.FIRST + 3;
    private static final int SRCATOP_MENU_ID = Menu.FIRST + 4;
    private static final int Save = Menu.FIRST + 5;

    public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    menu.add(0, COLOR_MENU_ID, 0, "Color").setShortcut('3', 'c');
    menu.add(0, EMBOSS_MENU_ID, 0, "Emboss").setShortcut('4', 's');
    menu.add(0, BLUR_MENU_ID, 0, "Blur").setShortcut('5', 'z');
    menu.add(0, ERASE_MENU_ID, 0, "Erase").setShortcut('5', 'z');
    menu.add(0, SRCATOP_MENU_ID, 0, "SrcATop").setShortcut('5', 'z');
    menu.add(0, Save, 0, "Save").setShortcut('5', 'z');

    return true;
    }

    public boolean onPrepareOptionsMenu(Menu menu) {
     super.onPrepareOptionsMenu(menu);
     return true;
     }

    public boolean onOptionsItemSelected(MenuItem item) {
    mPaint.setXfermode(null);
    mPaint.setAlpha(0xFF);

    switch (item.getItemId()) {
    case COLOR_MENU_ID:
      //  new ColorPickerDialog(this, this, mPaint.getColor()).show();
        new ColorPickerDialog(this, this , mPaint.getColor()).show();
        return true;
    case EMBOSS_MENU_ID:
        if (mPaint.getMaskFilter() != mEmboss) {
            mPaint.setMaskFilter(mEmboss);
        } else {
            mPaint.setMaskFilter(null);
        }
        return true;
    case BLUR_MENU_ID:
        if (mPaint.getMaskFilter() != mBlur) {
            mPaint.setMaskFilter(mBlur);
        } else {
            mPaint.setMaskFilter(null);
        }
        return true;
    case ERASE_MENU_ID:
       mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
       mPaint.setAlpha(0x80);
        return true;
    case SRCATOP_MENU_ID:

        mPaint.setXfermode(new PorterDuffXfermode(
                                            PorterDuff.Mode.SRC_ATOP));
        mPaint.setAlpha(0x80);
        return true;
    case Save:
        AlertDialog.Builder editalert = new AlertDialog.Builder(FingerPaintActivity.this);
            editalert.setTitle("Please Enter the name with which you want to Save");
            final EditText input = new EditText(FingerPaintActivity.this);
            LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.FILL_PARENT,
                    LinearLayout.LayoutParams.FILL_PARENT);
            input.setLayoutParams(lp);
            editalert.setView(input);
            editalert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                String name= input.getText().toString();
                Bitmap bitmap = mv.getDrawingCache();

             String path = Environment.getExternalStorageDirectory().getAbsolutePath(); 
                File file = new File("/sdcard/"+name+".png");           
                try 
                {
                    if(!file.exists())
                {
                    file.createNewFile();
                }
                    FileOutputStream ostream = new FileOutputStream(file);
                    bitmap.compress(CompressFormat.PNG, 10, ostream);
                    ostream.close();
                    mv.invalidate();                            
                } 
                catch (Exception e) 
                {
                    e.printStackTrace();
                }finally
                {

                    mv.setDrawingCacheEnabled(false);                           
                }
                }
            });

            editalert.show();       
        return true;    
    }
    return super.onOptionsItemSelected(item);
    }
    }

颜色选取器

package com.example.chart;

import android.app.Dialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.SweepGradient;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;


    public class ColorPickerDialog extends Dialog {

        public interface OnColorChangedListener {
            void colorChanged(int color);
        }

        private OnColorChangedListener mListener;
        private int mInitialColor;

        private static class ColorPickerView extends View {
            private Paint mPaint;
            private Paint mCenterPaint;
            private final int[] mColors;
            private OnColorChangedListener mListener;

            ColorPickerView(Context c, OnColorChangedListener l, int color) {
                super(c);
                mListener = l;
                mColors = new int[] {
                    0xFFFF0000, 0xFFFF00FF, 0xFF0000FF, 0xFF00FFFF, 0xFF00FF00,
                    0xFFFFFF00, 0xFFFF0000
                };
                Shader s = new SweepGradient(0, 0, mColors, null);

                mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                mPaint.setShader(s);
                mPaint.setStyle(Paint.Style.STROKE);
                mPaint.setStrokeWidth(32);

                mCenterPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
                mCenterPaint.setColor(color);
                mCenterPaint.setStrokeWidth(5);
            }

            private boolean mTrackingCenter;
            private boolean mHighlightCenter;

            @Override
            protected void onDraw(Canvas canvas) {
                float r = CENTER_X - mPaint.getStrokeWidth()*0.5f;

                canvas.translate(CENTER_X, CENTER_X);

                canvas.drawOval(new RectF(-r, -r, r, r), mPaint);
                canvas.drawCircle(0, 0, CENTER_RADIUS, mCenterPaint);

                if (mTrackingCenter) {
                    int c = mCenterPaint.getColor();
                    mCenterPaint.setStyle(Paint.Style.STROKE);

                    if (mHighlightCenter) {
                        mCenterPaint.setAlpha(0xFF);
                    } else {
                        mCenterPaint.setAlpha(0x80);
                    }
                    canvas.drawCircle(0, 0,
                                      CENTER_RADIUS + mCenterPaint.getStrokeWidth(),
                                      mCenterPaint);

                    mCenterPaint.setStyle(Paint.Style.FILL);
                    mCenterPaint.setColor(c);
                }
            }

            @Override
            protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                setMeasuredDimension(CENTER_X*2, CENTER_Y*2);
            }

            private static final int CENTER_X = 100;
            private static final int CENTER_Y = 100;
            private static final int CENTER_RADIUS = 32;

            private int floatToByte(float x) {
                int n = java.lang.Math.round(x);
                return n;
            }
            private int pinToByte(int n) {
                if (n < 0) {
                    n = 0;
                } else if (n > 255) {
                    n = 255;
                }
                return n;
            }

            private int ave(int s, int d, float p) {
                return s + java.lang.Math.round(p * (d - s));
            }

            private int interpColor(int colors[], float unit) {
                if (unit <= 0) {
                    return colors[0];
                }
                if (unit >= 1) {
                    return colors[colors.length - 1];
                }

                float p = unit * (colors.length - 1);
                int i = (int)p;
                p -= i;

                // now p is just the fractional part [0...1) and i is the index
                int c0 = colors[i];
                int c1 = colors[i+1];
                int a = ave(Color.alpha(c0), Color.alpha(c1), p);
                int r = ave(Color.red(c0), Color.red(c1), p);
                int g = ave(Color.green(c0), Color.green(c1), p);
                int b = ave(Color.blue(c0), Color.blue(c1), p);

                return Color.argb(a, r, g, b);
            }

            private int rotateColor(int color, float rad) {
                float deg = rad * 180 / 3.1415927f;
                int r = Color.red(color);
                int g = Color.green(color);
                int b = Color.blue(color);

                ColorMatrix cm = new ColorMatrix();
                ColorMatrix tmp = new ColorMatrix();

                cm.setRGB2YUV();
                tmp.setRotate(0, deg);
                cm.postConcat(tmp);
                tmp.setYUV2RGB();
                cm.postConcat(tmp);

                final float[] a = cm.getArray();

                int ir = floatToByte(a[0] * r +  a[1] * g +  a[2] * b);
                int ig = floatToByte(a[5] * r +  a[6] * g +  a[7] * b);
                int ib = floatToByte(a[10] * r + a[11] * g + a[12] * b);

                return Color.argb(Color.alpha(color), pinToByte(ir),
                                  pinToByte(ig), pinToByte(ib));
            }

            private static final float PI = 3.1415926f;

            @Override
            public boolean onTouchEvent(MotionEvent event) {
                float x = event.getX() - CENTER_X;
                float y = event.getY() - CENTER_Y;
                boolean inCenter = java.lang.Math.sqrt(x*x + y*y) <= CENTER_RADIUS;

                switch (event.getAction()) {
                    case MotionEvent.ACTION_DOWN:
                        mTrackingCenter = inCenter;
                        if (inCenter) {
                            mHighlightCenter = true;
                            invalidate();
                            break;
                        }
                    case MotionEvent.ACTION_MOVE:
                        if (mTrackingCenter) {
                            if (mHighlightCenter != inCenter) {
                                mHighlightCenter = inCenter;
                                invalidate();
                            }
                        } else {
                            float angle = (float)java.lang.Math.atan2(y, x);
                            // need to turn angle [-PI ... PI] into unit [0....1]
                            float unit = angle/(2*PI);
                            if (unit < 0) {
                                unit += 1;
                            }
                            mCenterPaint.setColor(interpColor(mColors, unit));
                            invalidate();
                        }
                        break;
                    case MotionEvent.ACTION_UP:
                        if (mTrackingCenter) {
                            if (inCenter) {
                                mListener.colorChanged(mCenterPaint.getColor());
                            }
                            mTrackingCenter = false;    // so we draw w/o halo
                            invalidate();
                        }
                        break;
                }
                return true;
            }
        }

        public ColorPickerDialog(Context context,
                                 OnColorChangedListener listener,
                                 int initialColor) {
            super(context);

            mListener = listener;
            mInitialColor = initialColor;
        }

        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            OnColorChangedListener l = new OnColorChangedListener() {
                public void colorChanged(int color) {
                    mListener.colorChanged(color);
                    dismiss();
                }
            };

            setContentView(new ColorPickerView(getContext(), l, mInitialColor));
            setTitle("Pick a Color");
        }
        }
  • 在 1.受保护的无效上创建(捆绑保存实例状态) {
    超级.on创建(已保存实例状态);
    错误:创建(捆绑包)上的方法未定义对象
    类型2.new MyView(指画活动.this);
    错误:构造函数指画活动.MyView(指画活动)未定义
    3.set内容查看(mv);
    错误:他的方法集内容视图(指画活动.MyView)是未定义的类型指画活动
    4.公共布尔值在创建选项菜单(菜单菜单) {
    超级.on创建选项菜单(菜单);
    错误:创建选项菜单(菜单)上的方法未定义对象
    5.公共布尔值在准备选项菜单(菜单菜单) { 超级.on准备选项菜单(菜单);
    错误:准备选项菜单上的方法未定义对象
    6.新颜色拾取器类型(这个, 这个, mPaint.getColor()).show();
    错误:构造函数颜色拾取器诊断(指画活动,指画活动,整数)未定义
    1. 警报对话框生成器编辑 = 新的警报对话框生成器(指画活动.this);错误:构造函数 AlertDialog.Builder(指画活动)未定义
      8.最终 EditText 输入 = 新的编辑文本(指画活动.this)
      错误:构造函数 EditText(指画活动) 未定义
      9.返回超级.onOptions项目已选(项目);
      错误:选项上的方法项目选择(菜单项)未定义类型 对象
      这些是无法删除
      代码的错误 属于拉古南丹先生

共有1个答案

骆照
2023-03-14

FingerPaintActive应该扩展Active类!这会导致您的所有其他问题。然后类声明将如下所示:

public class FingerPaintActivity extends Activity implements ColorPickerDialog.OnColorChangedListener {

    // class content goes here

}

您扩展的确切< code>Activity类型将取决于您是否需要支持库功能。

 类似资料:
  • 问题内容: 取自Android的想法:从对话框中模糊和暗化背景窗口。我无法使对话框下的内容模糊。当调用eula.getWindow()时,我收到此错误: 对于类型AlertDialog.Builder,未定义方法getWindow() 随同主要活动中的以下代码一起显示出eula: 任何帮助是极大的赞赏。 问题答案: 是对话框类的方法,而不是对话框生成器的方法。您的代码应该看起来像这样: 请注意,尽

  • 我试图让它在用户按下登录时关闭我的jframe。然而,它不让我处理登录窗口。请帮帮我。谢谢你。

  • 问题内容: 尝试将类类型的对象添加到 JArray时 遇到以下错误。 这是我正在使用的代码: 在运行程序时,我将其命名如下: 如何转换 _JArray(JArray) 内的 AmountModel(类) 以被系统识别为JSON对象? 非常感谢您的回答。 谢谢。 问题答案: 为了将任意非原始POCO添加到中,您必须使用以下重载之一显式序列化它: (另请注意,我已更正了循环中的结束条件。它是,导致出现

  • 本文向大家介绍JavaScript定义类和对象的方法,包括了JavaScript定义类和对象的方法的使用技巧和注意事项,需要的朋友参考一下 本文实例讲述了JavaScript定义类和对象的方法。分享给大家供大家参考。具体方法如下: 在JS中,类和对象有多种不同的写法,因为本人对JS也不怎么熟,所以就本人的理解来写,如果哪位朋友发现有不对,请告之,共同学习. JS定义一个类有两种定法(我只知道这两种

  • 在下,出现一条红线,表示:TouchActions TapObjectsSue类型的方法tap(TapOptions)未定义

  • 我一直在做一个用Java编写国际象棋的项目。我有一个名为的抽象类,它有一个抽象方法和两个普通方法。每个棋子我都有一个类,它们都扩展了。 有一个类也代表棋盘,叫做。在这个类中,我有一个方法来检查给定位置的棋子是否属于另一个玩家。在这个方法中,我调用了一个来自类的方法,该方法获取名为的颜色。当我在一个棋子上调用这个方法时,它说“方法getColor()对于类型Piece是未定义的”,即使它是在类中创建