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

The Archive Base Latest Questions

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

I just create a app for writing the text on Screen using TouchEvent method.

  • 0

I just create a app for writing the text on Screen using TouchEvent method. It works fine. See this is code

public TouchEventView(Context context, AttributeSet attrs) {
    super(context, attrs);

    paint.setAntiAlias(true);
    paint.setColor(Color.WHITE);
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeJoin(Paint.Join.ROUND);
    paint.setStrokeWidth(5f);
}

@Override
protected void onDraw(Canvas canvas) {
    canvas.drawPath(path, paint);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
    float x = event.getX();
    float y = event.getY();
    switch (event.getAction()) {
    case MotionEvent.ACTION_DOWN:
        path.moveTo(x, y);
        return true;
    case MotionEvent.ACTION_MOVE:
        path.lineTo(x, y);
        break;
    default:
        return false;
    }
    invalidate();
    return true;

After, that i’ve written code for clear the content in layout : –

LinearLayout li = (LinearLayout)findViewById(R.id.linear);
    li.clearAnimation();

My Logcat

11-18 16:10:18.681: I/System.out(22859): This is a log message
11-18 16:10:18.681: E/Mein Tag(22859): Hello
11-18 16:10:20.581: W/KeyCharacterMap(22859): No keyboard for id 0
11-18 16:10:20.581: W/KeyCharacterMap(22859): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
11-18 16:10:21.721: D/AndroidRuntime(22859): Shutting down VM
11-18 16:10:21.721: W/dalvikvm(22859): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
11-18 16:10:21.731: E/AndroidRuntime(22859): FATAL EXCEPTION: main
11-18 16:10:21.731: E/AndroidRuntime(22859): java.lang.NullPointerException
11-18 16:10:21.731: E/AndroidRuntime(22859):    at de.vogella.android.touch.WriteOnScreenActivity.clear(WriteOnScreenActivity.java:47)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at de.vogella.android.touch.WriteOnScreenActivity.onOptionsItemSelected(WriteOnScreenActivity.java:38)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at android.app.Activity.onMenuItemSelected(Activity.java:2195)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:730)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:143)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:855)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:532)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at android.view.View$PerformClick.run(View.java:8816)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at android.os.Handler.handleCallback(Handler.java:587)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at android.os.Looper.loop(Looper.java:123)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at android.app.ActivityThread.main(ActivityThread.java:4627)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at java.lang.reflect.Method.invokeNative(Native Method)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at java.lang.reflect.Method.invoke(Method.java:521)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
11-18 16:10:21.731: E/AndroidRuntime(22859):    at dalvik.system.NativeStart.main(Native Method)
11-18 16:22:15.801: I/System.out(23179): This is a log message
11-18 16:22:15.811: E/Mein Tag(23179): Hello

When i press the clear button, i got Nullpointer Exception for this app. What am doing wrong?

Anyone Guide me.

  • 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:57:16+00:00Added an answer on May 27, 2026 at 12:57 am

    I’ve got the answer from (AndroidTechMe). I used onCreate(null) to clear the contents. Thanks mate.

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

Sidebar

Related Questions

I've just created a little app that programmatically compiles code using the C# Compiler,
I've got a minimal app I just created, using VS 2008 SP1 on Vista
I'm writing a simple console client-server app using MSMQ. I'm attempting to run it
I'm writing a BlackBerry app in Java using the BlackBerry Java API (OS 4.7
hey guys I'm just writing a name getter app as I'm learning android and
I am writing a web app using TurboGears, and in that app the users
i am writing an app to compare products, using Python and GAE. The products
I'm writing a simple winforms app in C#. I create a worker thread and
I am writing a url shortener app and I would like to also create
I am having problems writing a piece of code for android. I am using

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.