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

  • Home
  • SEARCH
  • 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 4323614
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:01:32+00:00 2026-05-21T09:01:32+00:00

I follow the original android API and use the monodroid to write a very

  • 0

I follow the original android API and use the monodroid to write a very simple CustomView to draw a rectangle. Once I enter the application, it automatically quites. While I write a pure android with eclipse, it works fine. Or when I delete the drawRect method code, it works fine too. Does anyone know this or something wrong I did?

Here attaches the apps code:

[Activity1.cs]

int count = 1;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        // Get our button from the layout resource,
        // and attach an event to it
        Button button = FindViewById<Button>(Resource.Id.MyButton);
        LinearLayout layoutRoot = FindViewById<LinearLayout>(Resource.Id.LayoutRoot);
        layoutRoot.AddView(new DrawableView(this));

        button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
    }

[DrawableView.cs]

protected override void OnDraw(Android.Graphics.Canvas canvas)
    {
        base.OnDraw(canvas);
        canvas.DrawRect(new Rect(10, 10, 100, 100), new Paint { Color = Color.Red });
    }

this is the code I use in the eclipse:

public class DrawableView extends View {

public DrawableView(Context context) {
    super(context);
    // TODO Auto-generated constructor stub
}

@Override
protected void onDraw(Canvas canvas) {
    // TODO Auto-generated method stub
    super.onDraw(canvas);
    Paint paint = new Paint();
    paint.setColor(Color.RED);
    canvas.drawRect(new Rect(10, 10, 110, 110), paint);
}

}

Thanks a lot.
Howard

  • 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-21T09:01:32+00:00Added an answer on May 21, 2026 at 9:01 am

    You need to check the android log to see what the error is:

    http://mono-android.net/Documentation/Guides/Android_Debug_Log

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

Sidebar

Related Questions

I'm new to Android application development and I'm currently experimenting with various UI ideas.
This question is sort of a follow-up to my original question here . Let's
I am new to JUnit and Android and good test documentation for working with
I am working on an Android app that displays photos which are downloaded from
I have to convert a byte array to string in Android, but my byte
When contributing to a very old, and apparently no longer maintained, open-source or public
I am having an issue with using TabHost in a new Intent of type
This is the before: http://img22.imageshack.us/img22/5310/beforedes.jpg znd after: http://img189.imageshack.us/img189/8890/afterr.jpg EDIT:: Now that I look at
I'm interested in playing around with GUIs and I've been trying to set up
A traditional C++ class (just some random declarations) might resemble the following: class Foo

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.