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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:33:37+00:00 2026-05-27T14:33:37+00:00

Some of my coding is as follows. The first button (button2) is for exit

  • 0

Some of my coding is as follows. The first button (button2) is for exit which is working fine on my emulator and phone but the (button 1) which is supposed to take input from a TextView and add 777 and then display as a toast message is not working in either of them.

public class TimerCodeActivity extends Activity {

protected TextView timebox;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.timerlayout);

    timebox = (TextView) findViewById(R.id.timebox);

    Button button2 = (Button) findViewById(R.id.button2);
    button2.setOnClickListener(new OnClickListener(){

        @Override    
        public void onClick(View v) {
            finish();
            System.exit(0);}
    });    

    Button button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new OnClickListener(){    

        @Override
        public void onClick(View v) {  
            String timeboxRepresentation = (String) timebox.getText();

             int Digit = Integer.parseInt(timeboxRepresentation.substring(0,2));
             int total = Digit + 777;

             Toast.makeText(TimerCodeActivity.this, String.valueOf(total), Toast.LENGTH_LONG).show();
        }
    });
}}

Thank you in advance for any assistance.

  • 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-27T14:33:38+00:00Added an answer on May 27, 2026 at 2:33 pm

    try this:

    public class TimerCodeActivity extends Activity {
    
    protected TextView timebox;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timerlayout);
    
        timebox = (TextView) findViewById(R.id.timebox);
    
        Button button2 = (Button) findViewById(R.id.button2);
        button2.setOnClickListener(new OnClickListener(){
    
            @Override    
            public void onClick(View v) {
                finish();
            }
        });    
    
        Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new OnClickListener(){    
    
            @Override
            public void onClick(View v) {
                // Use toString to get the TextView content  
                String timeboxRepresentation = timebox.getText().toString();
    
                 int Digit = Integer.parseInt(timeboxRepresentation.substring(0,2));
                 int total = Digit + 777;
    
                 Toast.makeText(TimerCodeActivity.this, String.valueOf(total), Toast.LENGTH_LONG).show();
            }
        });
    }}
    

    and just remove

    System.exit(0);
    

    it’s useless.

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

Sidebar

Related Questions

I am just starting with coding some JSP, which I find isn't all that
I'm doing some coding in JSP/Java (without any framework, or other strange things) and
I've noticed in some coding people use icicle with the onCreate method, and I
I use emacs to do some coding, and text editing. When I create a
We are currently going through the long process of writing some coding standards for
I'm coding some c# against Active Directory and have tried endlessly to get this
I'm doing some maintenance coding on a webapp and I am getting a javascript
Say you're coding some kind of web application. Something where people can contribute content,
I'm doing some JAVA coding at home and at work. At home i have
I'm going to start coding some automated tests of our presentation soon. It seems

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.