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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:33:33+00:00 2026-06-15T15:33:33+00:00

I have added a toggleButton, but it is not showing up and I cannot

  • 0

I have added a toggleButton, but it is not showing up and I cannot figure out why. I have completed the Android tutorial, and have looked back at the code, as well as many other sources. The objective is to have the program pause when the button is ON. At the moment, the button will not even show up on the user interface. Any suggestions?

<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"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true" />

    <ToggleButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:onClick="pauseCounter" />

</RelativeLayout>

package com.evorlor.counter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Intent counter = new Intent(MainActivity.this, Counter.class);

        startActivity(counter);

    }

    public void pauseCounter(View view) {
        Intent pause = new Intent(this, Pause.class);
        startActivity(pause);
    }

    // @Override
    // public boolean onCreateOptionsMenu(Menu menu) {
    // // Inflate the menu; this adds items to the action bar if it is present.
    // getMenuInflater().inflate(R.menu.activity_main, menu);
    // return true;
    // }

}

package com.evorlor.counter;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class Pause extends Activity{

    public void onCreate(Bundle instPause) {
        super.onCreate(instPause);

        TextView tv = new TextView(this);

        tv.setTextSize(250);
        tv.setText("PAUSE");
        setContentView(tv);

    }
}

Here is my Counter class. It is messy. Sorry. This is as close as I have come so far. Help would be very appreciated! I have spent a lot of time on this measly button! Thanks!

package com.evorlor.counter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.MotionEvent;
import android.widget.TextView;
import android.widget.ToggleButton;

public class Counter extends Activity {

    private int count = 0;
    private int hiCount = 0;
    private boolean capCount = false;

    public void onCreate(Bundle instCounter) {
        super.onCreate(instCounter);

        TextView tv = new TextView(this);

        tv.setTextSize(250);
        if (count < 10000 && capCount == false) {

            tv.setText(Integer.toString(count));
        } else {
            capCount = true;
            if (count >= 10000) {
                hiCount += 10;
                count -= 10000;
            }
            if (hiCount < 100) {

                tv.setText(hiCount + "k+" + count);
            } else {
                tv.setText("Over\n100k");
            }
        }
        tv.setGravity(Gravity.CENTER);

        setContentView(tv);

        ToggleButton butPause = new ToggleButton(this);

        if (butPause == null) {
            Intent pause = new Intent(this, Pause.class);
            startActivity(pause);
        }

    }
    // public void pauseCounter(View view) {
    // Intent pause = new Intent(this, Pause.class);
    // startActivity(pause);
    // }

}
  • 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-15T15:33:35+00:00Added an answer on June 15, 2026 at 3:33 pm
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        Intent counter = new Intent(MainActivity.this, Counter.class);
    
        startActivity(counter);
    
    }
    

    You are starting a new activity right away. thats not a good idea.
    You are going to see what is in your Counter activity, not what is in your main activity, reason you don’t see your toggle button. Comment out startActivity() just to check.

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

Sidebar

Related Questions

I have added a button inside a loginview, but then this code is not
I have added the sdk files like dropbox website says, but I can't figure
I have added the back ground color as an image to uiwebview but it
I have added the following block of code to my WP7 app and not
I have added custom attribute with the code my_price with Catalog Input Type for
I have added some code which compiles cleanly and have just received this Windows
I have added the required assemblies and registered the NVelocityViewFactory in global.asax.cs page but
I have added a bcc field to my email that I am sending out
I have added a button as shown in the code below, I have added
Have added the following code to my SQL query: (Note cut down version) DECLARE

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.