Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8906171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:34:59+00:00 2026-06-15T02:34:59+00:00

I think that my problem is minor but I can’t find solution. I am

  • 0

I think that my problem is minor but I can’t find solution. I am trying to make application which will help me to make WEB pages and I want to make application which will put graphic element on the screen.

I made drawable png images of rectangles and I can put them on the screen where I want, no problem, but I can not make new graphic/bitmap.

How I can put new graphics object on the screen when I press in meni DIV or iFrame?

public class Objects extends View {
    private float X;
    private float Y;
    private Paint myPaint;
    final String C_DIV = "DIV";
    final String C_TABLE = "Table";
    final String C_IFRAME = "iFrame";
    final String C_LIST = "List";
    Canvas canvas;
    Bitmap divimg = BitmapFactory.decodeResource(getResources(), R.drawable.div);
    Bitmap iframeimg = BitmapFactory.decodeResource(getResources(), R.drawable.iframe);
    Bitmap img = null;
    String objectname = " ";

    public Objects(Context context) {
        super(context);
        myPaint = new Paint();
    }

    public void HTMLObjects(String object) {
        Log.d(object, "see");
        if (object.equals(C_DIV)) {
            myPaint.setColor(Color.GREEN);
            img = Bitmap.createBitmap(divimg);
            objectname = "DIV";
        }
        if (object.equals(C_IFRAME)) {
            myPaint.setColor(Color.BLUE);
            img = Bitmap.createBitmap(iframeimg);
            objectname = "iFrame";
        }
    }

    public boolean onTouchEvent(MotionEvent event) {
        int action = event.getAction();
        switch (action) {
            case MotionEvent.ACTION_DOWN:
                X = (int) event.getX();
                Y = (int) event.getY();
                break;
            case MotionEvent.ACTION_MOVE:
            case MotionEvent.ACTION_UP:
            case MotionEvent.ACTION_CANCEL:
                X = (int) event.getX();
                Y = (int) event.getY();
                break;
        }
        return true;
    }

    public void onDraw(Canvas canvas) {
        if (img != null) {

            canvas.drawBitmap(img, X - 50, Y - 50, myPaint);
            canvas.drawText(objectname, X, Y - 50, myPaint);
        }
        invalidate();
    }
}

This is a class which I am calling from the activity Workspace with

ob.HTMLObjects((String) item.getTitle());

and I am sending information which menu is pressed.

I do not know how to make new/different object/bitmap when I pressed DIV or iFrame.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T02:35:01+00:00Added an answer on June 15, 2026 at 2:35 am

    Try these version. I replaces x,y,img,objectname with according lists:

    public class Objects extends View {
        private Paint myPaint;
        public final String C_DIV="DIV";
        public final String C_TABLE="Table";
        public final String C_IFRAME="iFrame";
        public final String C_LIST="List";
        private Canvas canvas;
        private Bitmap divimg= BitmapFactory.decodeResource(getResources(), R.drawable.div);
        private Bitmap iframeimg=BitmapFactory.decodeResource(getResources(), R.drawable.iframe);
        private List<Bitmap> images;
        private List<Float> xs;
        private List<Float> ys;
        private List<String> objectNames;
    
        public Objects(Context context) {
            super(context);
            myPaint = new Paint();
            images = new ArrayList<Bitmap>();
            xs = new ArrayList<Float>();
            ys = new ArrayList<Float>();
            objectNames = new ArrayList<String>();
        }
    
        public void HTMLObjects(String object){
            Log.d(object, "see");
            if (object.equals(C_DIV)) {
                myPaint.setColor(Color.GREEN);
                images.add(Bitmap.createBitmap(divimg));
                objectNames.add("DIV");
                xs.add(0F);
                ys.add(0F);
            }
            if (object.equals(C_IFRAME)){
                myPaint.setColor(Color.BLUE);
                images.add(Bitmap.createBitmap(iframeimg));
                objectNames.add("iFrame");
                xs.add(0F);
                ys.add(0F);
            }
        }
        public boolean onTouchEvent(MotionEvent event) {
            int action=event.getAction();
            if (xs.isEmpty()) {
                return true;
            }
            int pos = xs.size() - 1;
            switch(action) {
                case MotionEvent.ACTION_DOWN:
                    xs.set(pos, event.getX());
                    ys.set(pos, event.getY());
                    break;
                case MotionEvent.ACTION_MOVE:
                case MotionEvent.ACTION_UP:
                case MotionEvent.ACTION_CANCEL:
                    xs.set(pos, event.getX());
                    ys.set(pos, event.getY());
                    break;
            }
            return true;
        }
        public void onDraw(Canvas canvas){
            for (int i = 0; i < images.size(); i++) {
                float x = xs.get(i);
                float y = ys.get(i);
                canvas.drawBitmap(images.get(i), x-50, y-50, myPaint);
                canvas.drawText(objectNames.get(i), x, y-50, myPaint);
            }
            invalidate();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a pretty minor problem that I think can be resolved by re-thinking
I think that this problem can be sorted using reflection (a technology which I'm
i have a problem that i can't solve ! (sqlite3, but i think it
I have a peculiar problem, which I think that a lot of other people
I'm having a problem with logic programming, but I think that could be another
My problem is one that you would think is quite common, but I haven't
A recent question contains a problem that I many times used to think about
Hi all I am having some problems that I think can be attributed to
I am trying to create a simple .bat file that will generate a .html
There's a minor but annoying bug, I think, in the Eclipse built-in Java formatter.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.