如何在android中添加多个可以在画布上编辑的文本?

时间:2016-08-04 08:38:12

标签: android canvas arraylist android-edittext

这里我想添加Edittext警告对话框,我可以在android中添加多个文本。如何在数组中存储edittext?

 if (c.getImage() == 3) {
        // canvas.rotate(45);
        mPaint.setTextSize(37);
        mPaint.setStyle(Style.FILL);
        canvas.drawText(c.getEdittext(),xTouch1, yTouch1, mPaint);


        // canvas.drawText("Hello",40,180,mPaint);

    }
        else if (c.getImage() == 3) {


        editTexts.add(new EditText(c.getEdittext(),xTouch1,yTouch1,mPaint));
        canvas.drawText(c.getEdittext(),xTouch1, yTouch1, mPaint);

        for (EditText l : editTexts) {

            canvas.drawText(c.getEdittext(), xTouch1, yTouch1, mPaint);

        }
        }
        c.setImage(0);

先谢谢。

1 个答案:

答案 0 :(得分:2)

我找到了如何在画布上添加多个文字的答案

class etext {
    float startX, startY, stopX, stopY;
    String etext1;

    public etext(String etext1, float startx, float stopY) {
        this.etext1 = etext1;
        this.startX = startx;
        this.stopY = stopY;

    }

为EditText创建一个特定类,然后在`

之后
if (c.getImage() == 3) {

        mPaint.setTextSize(37);
        mPaint.setStyle(Style.FILL);
        //  canvas.drawText(c.getEdittext(),xTouch1, yTouch1, mPaint);
        canvas.drawText(c.getEdittext(), xTouch1, yTouch1, mPaint);
        editTexts.add(new etext(c.getEdittext().toString(), xTouch1, yTouch1));

    }

`