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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:12:56+00:00 2026-06-08T05:12:56+00:00

package com.android.tapme; import android.os.Bundle; import android.app.Activity; import android.widget.*; import android.view.*; import android.os.CountDownTimer; public class

  • 0
package com.android.tapme;

import android.os.Bundle;
import android.app.Activity;
import android.widget.*;
import android.view.*;
import android.os.CountDownTimer;

public class TapMe extends Activity {

private int countValue=0;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_tap_me);
    checkTapValue();
}
private void checkTapValue()
{
    Button tapButton=(Button)findViewById(R.id.tapButton);
    tapButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            countValue++;
            TextView textView;
            textView = (TextView) findViewById(R.id.textView1);
            textView.setTextSize(40);
            textView.setText(Integer.toString(countValue)); 
        }
    });     

}
@Override
protected void onResume()
{
    super.onResume();
    checkTapValue();
}
}
     class MyCount extends CountDownTimer{
TextView tv;
   public MyCount(long millisInFuture, long countDownInterval) {
        super(60000, 1000);
        }
        @Override
        public void onFinish(){}
        @Override
        public void onTick(long millisUntilFinished) {
        tv.setText((int) (millisUntilFinished/1000));
        }   
 }

This is my .java file. The countdown timer should display 60 seconds and count down per second. Thing is everything works fine but the countdown timer. It doesn’t display.
Can anyone point out what I did wrong, please?

Also, here’s the layout file.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >

<Button
    android:id="@+id/tapButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:layout_marginTop="186dp"
    android:padding="15dp"
    android:text="@string/tap_me"
    android:textSize="32dp" />


<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/textView3"
    android:layout_alignParentTop="true"
    android:layout_marginTop="85dp"
    android:padding="@dimen/padding_medium"
    android:textColor="#000000"
    tools:context=".TapMe" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView2"
    android:layout_centerHorizontal="true"
    android:padding="@dimen/padding_medium"
    android:textColor="#000000"
    tools:context=".TapMe" />

 </RelativeLayout>

EDIT
@imran
I’ve done this. No difference.

class MyCount extends CountDownTimer{
    TextView tv = (TextView) findViewById(R.id.textView2);
       public MyCount(long millisInFuture, long countDownInterval) {
            super(60000, 1000);
            }
            private TextView findViewById(int textview2) {
        // TODO Auto-generated method stub
        return null;
    }
            @Override
            public void onFinish(){}
            @Override
            public void onTick(long millisUntilFinished) {
            tv.setText("" +(int) (millisUntilFinished/1000));
            }   
     }
  • 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-08T05:12:59+00:00Added an answer on June 8, 2026 at 5:12 am

    try this updated code. works just fine. you didn’t started the countdown timer at all and never initialized the textview in timer. i changed these errors in below code

    import android.app.Activity;
    import android.os.Bundle;
    import android.os.CountDownTimer;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;
    
    public class TapMe extends Activity {
    
        private int countValue = 0;
        private TextView textView;
        private TextView textView2;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_tap_me);
    
            textView = (TextView) findViewById(R.id.textView1);
            textView.setTextSize(40);
            textView2 = (TextView) findViewById(R.id.textView2);
            textView2.setTextSize(40);
    
            checkTapValue();
    
            MyCount myCount = new MyCount(60000, 1000);
            myCount.start();
    
        }
    
        private void checkTapValue() {
            Button tapButton = (Button) findViewById(R.id.tapButton);
            tapButton.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
    
                    countValue++;
                    textView.setText(Integer.toString(countValue));
    
                }
            });
    
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            checkTapValue();
        }
    
        class MyCount extends CountDownTimer {
    
            public MyCount(long millisInFuture, long countDownInterval) {
                super(millisInFuture, countDownInterval);
            }
    
            @Override
            public void onFinish() {
            }
    
            @Override
            public void onTick(long millisUntilFinished) {
                System.out.println(millisUntilFinished);
                textView2.setText("" + (int) (millisUntilFinished / 1000));
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

package com.android.SMStest; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.telephony.SmsManager; import android.view.View; import android.widget.Button;
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;
I got the following code inside my templateApp.java: package com.android.templateApp; import android.app.Activity; import android.os.Bundle;
package com.android.project; import android.app.Activity; import android.os.Bundle; import org.ksoap2.SoapEnvelope; import org.ksoap2.serialization.SoapObject; import org.ksoap2.serialization.SoapSerializationEnvelope; import org.ksoap2.transport.HttpTransportSE;
MakeMissedCallActivity.java: package com.android.main; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.Uri; import android.os.Bundle; import
I'm trying out the LoaderCursor example in the API Demo: package com.example.android.apis.app; import android.app.Activity;
This is my FragmentListArraySupport.java package com.test.methods; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import android.support.v4.app.ListFragment; import android.util.Log;
Please take a look at my code: package com.yarin.android.Examples_04_23; import android.app.Activity; import android.app.Notification; import
I made a simple car mileage calculator. package com.android.carmanager; import com.android.carmanager.CarManagerActivity; import android.os.Bundle; import
I have a config file like package com.mypackage.referencedata.config; @Configuration @ComponentScan (com.mypackage.referencedata.*) public class ReferenceDataConfig

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.