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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:54:50+00:00 2026-06-16T03:54:50+00:00

I am looking for widget Switch . Not switch statement or switch activity etc.

  • 0

I am looking for widget Switch. Not switch statement or switch activity etc.

There was very rare tutorial on web.

My problem is graphical layout in xml cannot see the switch.

my xml

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_margin="10dp" >

    <TextView
        android:id="@+id/text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="推送通知"
        android:textColor="#ffffff"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/status"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/text"
        android:layout_marginTop="5dp"
        android:textColor="#ffffff"
        android:textSize="15dp" />

    <Switch
        android:id="@+id/switch"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:textOff="关"
        android:textOn="开" />
</RelativeLayout>

The error occurs at the there.

Error

Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.

NOTE: This project contains resource errors, so aapt did not succeed, which can cause rendering failures. Fix resource problems first.

Failed to find style 'switchStyle' in current theme
java.lang.NullPointerException
Exception details are logged in Window > Show View > Error Log

I got no idea how to do it?

  • 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-16T03:54:51+00:00Added an answer on June 16, 2026 at 3:54 am

    Your AndroidManifest.xml should have

     <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="16" />
    

    Because Switch widget supports 14 and above API level only..

    A simple example for you..

    main.xml
    <GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    
                <Switch
                    android:id="@+id/bluetooth"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="32dip"
                    android:text="Bluetooth"
                    />
    
    </GridLayout>
    
    ur .java
    
    
    
    package time.pass;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.widget.CompoundButton;
    import android.widget.Switch;
    import android.widget.Toast;
    
    public class TimePass extends Activity implements CompoundButton.OnCheckedChangeListener {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        setContentView(R.layout.activity_time_pass );
    
        Switch s = (Switch) findViewById(R.id.bluetooth);
        if (s != null) {
            s.setOnCheckedChangeListener(this);
        }
    }
    
    
    @Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
       Toast.makeText(this, "Bluetooth is " + (isChecked ? "on" : "off"),
               Toast.LENGTH_SHORT).show();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for some sort of TimeRange widget in Javascript/CSS/jQuery. I'm not looking for
I am looking to create a web widget that can be easily integrated into
Well... here's a problem it looks like I'm not the first to experience looking
I was looking at the Soundlcoud Widget docs http://developers.soundcloud.com/docs/widget# I noticed there is a
I am looking for a widget that I can use. What am after is
Looking for a jQuery MultiSelect Widget that can handle thousands of items. Really like
I am looking to create a javascript widget that can be hosted on other
I am looking for a multi-select jquery based two-column transfer widget having a look
I am looking for a searchable multiple select javascript widget that can handle filtering
I'm looking into using the jQuery UI autocomplete widget to implement user lookup by

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.