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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:19:47+00:00 2026-05-31T11:19:47+00:00

I am very new to Java and android. my 1st app using canvas and

  • 0

I am very new to Java and android. my 1st app using canvas and paint. for some reason I get a force close whenever I try using the drawText method.. Please help.
I am basically trying to display text in a specific x,y coordinate. which will need updates throughout game play, my code:

public class MyGame extends Main {

 TextView timeDisplay;
 public String clock;
 int x_pos = 10; 
 int y_pos = 100; 
 int radius = 20;
 float x = 10;
 float y = 20;
 android.graphics.Paint p;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {

     setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
        super.onCreate(savedInstanceState);
       setContentView(R.layout.main);
        // setup Drawing view

        Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(b);
        c.drawText("test", 30, 0,x,y, p);   <-- if I comment this out, no force close...

Your help is appreciated.

  • 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-31T11:19:48+00:00Added an answer on May 31, 2026 at 11:19 am

    initialize p as follow

    Paint p = new Paint(); 
    p.setColor(Color.WHITE); 
    p.setStyle(Style.FILL); 
    

    and then use

    c.drawText("test", 30, 0,x,y, p);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to java and am working on my first Android app. I
I am very new to java and trying to develop an Android app called
I am very new to Java as well as Android programming. I was attempting
I have been slowing learning and building my first android app. I'm VERY new
Just a disclaimer, I'm very new to both android and Java. The end product
I'm very new to android, in fact only started yesterday. I managed to get
ok so im very new to android development and fairly new to java and
I am very new to the android platform thus java so i have a
I am very new to Android application development. I successfully added some backgrounds to
I'm very new to developing on Android and the Java language in general and

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.