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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:31:36+00:00 2026-06-07T10:31:36+00:00

so my stopwatch class worked fine until I made some changes in XML code

  • 0

so my stopwatch class worked fine until I made some changes in XML code of it. Basiclly what I did is change some sizes and layout_margins..nothing special

heres the xml code, and logcat

  <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >

         <Chronometer
            android:id="@+id/chronometer1"
            android:layout_width="57dp"
            android:layout_height="49dp"
             android:text="Chronometer"
            android:layout_marginTop="150dp"
            android:layout_gravity="center"
            android:textSize="50dp"

            />


         <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <Button
            android:id="@+id/bt_sm_start"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Start"
            android:layout_marginLeft="25dp"
            android:textSize="20dp"
            android:layout_marginTop="50dp"



            />

        <Button
            android:id="@+id/bt_sm_pause"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="20dp"
            android:layout_marginTop="50dp"
            android:text="Pause"
            android:layout_marginLeft="25dp"
             />

        <Button
            android:id="@+id/bt_sm_stop"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="50dp"
            android:textSize="20dp"
            android:text="Stop"
            android:layout_marginLeft="25dp"
             />



       </LinearLayout>



    </LinearLayout>

heres the logcat

07-12 20:35:46.253: I/Process(360): Sending signal. PID: 360 SIG: 9
07-12 20:37:25.973: D/AndroidRuntime(395): Shutting down VM
07-12 20:37:25.973: W/dalvikvm(395): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-12 20:37:25.993: E/AndroidRuntime(395): FATAL EXCEPTION: main
07-12 20:37:25.993: E/AndroidRuntime(395): java.lang.RuntimeException: Unable to start activity ComponentInfo{mioc.diver/mioc.diver.StopwatchMenu}: java.lang.ClassCastException: android.widget.Chronometer
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.os.Looper.loop(Looper.java:123)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.ActivityThread.main(ActivityThread.java:3683)
07-12 20:37:25.993: E/AndroidRuntime(395):  at java.lang.reflect.Method.invokeNative(Native Method)
07-12 20:37:25.993: E/AndroidRuntime(395):  at java.lang.reflect.Method.invoke(Method.java:507)
07-12 20:37:25.993: E/AndroidRuntime(395):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-12 20:37:25.993: E/AndroidRuntime(395):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-12 20:37:25.993: E/AndroidRuntime(395):  at dalvik.system.NativeStart.main(Native Method)
07-12 20:37:25.993: E/AndroidRuntime(395): Caused by: java.lang.ClassCastException: android.widget.Chronometer
07-12 20:37:25.993: E/AndroidRuntime(395):  at mioc.diver.StopwatchMenu.Create(StopwatchMenu.java:30)
07-12 20:37:25.993: E/AndroidRuntime(395):  at mioc.diver.StopwatchMenu.onCreate(StopwatchMenu.java:23)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-12 20:37:25.993: E/AndroidRuntime(395):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-12 20:37:25.993: E/AndroidRuntime(395):  ... 11 more

here’s java code of this activity

 package mioc.diver;

    import android.app.Activity;
    import android.os.Bundle;
    import android.os.SystemClock;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.Chronometer;

    public class StopwatchMenu extends Activity implements OnClickListener{
        int pause1 = 0;
        long stopped = 0;
        Button start;
        Button stop;
        Button pause;
        Chronometer stopwatch;

        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.stopwatch_menu);
            Create();


    }
        private void Create() {
            // TODO Auto-generated method stub

            start = (Button) findViewById(R.id.bt_sm_start);
            stop = (Button) findViewById(R.id.bt_sm_stop);
            pause = (Button) findViewById(R.id.bt_sm_pause);
            stopwatch = (Chronometer) findViewById(R.id.chronometer1);

            start.setOnClickListener(this);
            stop.setOnClickListener(this);
            pause.setOnClickListener(this);

        }
        public void onClick(View v) {

            // TODO Auto-generated method stub
            switch(v.getId())
            {
            case R.id.bt_sm_start:
                if(pause1 == 0)
                stopwatch.setBase(SystemClock.elapsedRealtime());
                //stopwatch.setBase(stopped);
            stopwatch.start();

            pause1 = 0;

                break;
            case R.id.bt_sm_pause:
                stopwatch.stop();
                stopped = 0;
                stopped = stopwatch.getBase();
                pause1 = 1;


                break;
            case R.id.bt_sm_stop:
                stopwatch.stop();
                stopwatch.setBase(SystemClock.elapsedRealtime());




            }
        }


    }
  • 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-07T10:31:38+00:00Added an answer on June 7, 2026 at 10:31 am

    Have you tried cleaning your project?

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

Sidebar

Related Questions

I wrote some code which monitors the output of Stopwatch using a tight loop.
I'm making an application that needs some pretty tight timing, and the Stopwatch class
At MSDN page for Stopwatch class I discovered link to interesting article which makes
Hola check this code. var watch = new Stopwatch(); watch.Start(); var request = HttpWebRequest.Create(new
Ideally I would like to have something similar to the Stopwatch class but with
I setup some stop watch calls in my code to measure some code blocks
Is there a stopwatch Class (preferably opensource) providing the same service as Diagnostics.TStopwatch in
What does ElapsedTicks and Elapsed.Ticks in the Stopwatch class mean? When could the meaning
I've been profiling a method using the stopwatch class, which is sub-millisecond accurate. The
I'm trying to observe an int property (totalSeconds) in a class (StopWatch) where total

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.