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 6842547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:06:49+00:00 2026-05-27T00:06:49+00:00

I have created one view, view code is, public class MyDraw extends View{ //List<Point>

  • 0

I have created one view, view code is,

   public class MyDraw extends View{

    

    //List<Point> mArryLstpoints = new ArrayList<Point>();
    Paint paint =new Paint();
    Paint mPaintAlphabet = new Paint();
    public MyDraw(Context context) {
        super(context);
        
    
        paint.setColor(Color.BLUE);
        paint.setAntiAlias(true);
         
    
        // TODO Auto-generated constructor stub
    }
    public MyDraw(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
             
        paint.setColor(Color.BLUE);
        paint.setAntiAlias(true);
        
        mPaintAlphabet.setDither(true);
        mPaintAlphabet.setColor(0xFFFF0000);
        mPaintAlphabet.setStyle(Paint.Style.STROKE);
        mPaintAlphabet.setStrokeJoin(Paint.Join.ROUND);
        mPaintAlphabet.setStrokeCap(Paint.Cap.ROUND);
        mPaintAlphabet.setStrokeWidth(3);
        mPaintAlphabet.setTextSize(400);
    }
    
    public void onDraw(Canvas canvas){
        canvas.drawColor(Color.GRAY);
        canvas.drawText("A",100,350, mPaintAlphabet);
        System.out.println("in on draw");
        for(Point mPoint:MyAlphabetsActivity.mArryLstpoints)
        canvas.drawCircle(mPoint.x, mPoint.y, 12, paint);
        
    }
    
    }

I want use this view in layout and I want to set background images for the view. I am using following code,

  <?xml version="1.0" encoding="utf-8"?>

  <com.qteq.myalphabets.MyDraw
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:id="@+id/android:list"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" ></com.qteq.myalphabets.MyDraw>

My activity class is,

public class MyAlphabetsActivity extends Activity {
    /** Called when the activity is first created. */

    MyDraw mMyDraw;
    Button mBtnOk;
    AttributeSet attributeSet;
    public static List<Point> mArryLstpoints = new ArrayList<Point>();
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /*
         * getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
         * WindowManager.LayoutParams.FLAG_FULLSCREEN);
         */
        /*
         * mMyDraw=new MyDraw(this); setContentView(mMyDraw);
         * mMyDraw.requestFocus();
         */
        mMyDraw = (MyDraw) findViewById(R.id.mMyDraw_layout);
        mMyDraw.bringToFront();
        mMyDraw.requestFocus();
        mMyDraw.setOnTouchListener(new OnTouchListener() {
            
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // TODO Auto-generated method stub
                Point mPoint=new Point();
                mPoint.x=event.getX();
                mPoint.y=event.getY();
                System.out.println("in on touch");
                mArryLstpoints.add(mPoint);
                System.out.println("Array list is-----"+mArryLstpoints);
                
                setContentView(R.layout.main);
                return true;
            }
        });
        // setContentView(R.layout.main);
    }
}
    class Point{
        public float srtx;
        float x, y;
        
        @Override
        public String toString() {
            System.out.println("in on point");
            return x + ", " + y;       
    }
    }

and Displaying and onTouch Method called only one time.

  • 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-05-27T00:06:49+00:00Added an answer on May 27, 2026 at 12:06 am

    You are Adding view with fill_parent width and height , so no space to add other views like buttons and images .

    one of the possible implementation

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
           android:id="@+id/android:list"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent">
    
      <com.qteq.myalphabets.MyDraw
       xmlns:android="http://schemas.android.com/apk/res/android"
           android:id="@+id/android:list"
           android:layout_width="fill_parent"
           android:layout_height="wrap_contentt" ></com.qteq.myalphabets.MyDraw>
    <Button/>
    <ImageView/>
    </LinearLayout>
    

    Dont forget to add constructor

    public MyDraw(Context context, AttributeSet attributeSet) {
            super(context, ttributeSet);
    

    in MyDraw.java

    ******** *editing* ******

    in onTouch()
    return super(v, event) instead of true ;
    also check if you need to write setOnTouchListener() to view or canvas .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created one simple list view. i have two list view, my 1st list
I have created a new method in one of the project's controllers that it
I have created one table using the below command: create table Table1( Id int
I have created one aspx Page from that i need to access the property
I have created one application in flex that is accessing the Java webservice using
I have created one user named tuser with create database rights in SQL server
hello i have created one windows application in c# .net and its working fine
I have created a one-time subscription in SSRS report manager 2008. However I keep
I have created two JavaScript files. One file is "validators.js" and the other is
I have created a .NET DLL which makes some methods COM visible. One method

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.