Search code examples
javaandroidtogglebuttonnexus-7

Android ToggleButton showing up as normal button


My togglebutton shows up as a normal button. On the previous development platform (samsung galaxy s advance with android 4.2 & 2.3) the button appeared as a normal togglebutton. In the designer it also appears as a togglebutton. The problems started when I migrated to nexus 7 (early 2013) as development platform with android 4.3. I opened a new project and added a togglebutton - this one shows up fine on the nexus7 with android 4.3. When I copy the xml code from the working togglebutton app to my project it shows a normal button again.

I tried

   android:minSdkVersion="11"
   android:targetSdkVersion="11"

up to

   android:minSdkVersion="18"
   android:targetSdkVersion="18"

Xml of both of the layout files of both projects

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/tvHead"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:layout_marginLeft="18dp" android:layout_marginTop="16dp" android:text="Geef chauffeur op" android:textAppearance="?android:attr/textAppearanceLarge"/>

    <ListView
        android:id="@+id/lvChauffeurs"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" android:layout_alignLeft="@+id/tvHead" android:layout_alignParentRight="true" android:layout_alignParentTop="false" android:layout_below="@+id/tvHead">
    </ListView>
    <ProgressBar android:id="@+id/progressBar1"  style="@android:style/Widget.ProgressBar.Small" android:layout_width="wrap_content" android:layout_height="25dp" android:layout_alignParentTop="true" android:layout_toLeftOf="@+id/tvVersie" android:maxHeight="25dp" android:maxWidth="25dp" android:minHeight="20dp" android:minWidth="20dip" android:paddingTop="5dp" android:visibility="invisible"/>
    <TextView android:id="@+id/tvVersie" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/lvChauffeurs" android:layout_alignParentRight="true" android:layout_alignParentTop="true" android:text="Small Text" android:textAppearance="?android:attr/textAppearanceSmall" android:textSize="36px"/>
    <ToggleButton android:id="@+id/toggleButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_centerHorizontal="true" android:text="ToggleButton"/>
</RelativeLayout>

The manifest file from the project that displays the togglebutton as a togglebutton:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.tst"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.tst.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

And the manifest file from the project that displays the togglebutton as a normal button

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.####.#"
    android:versionCode="8"
    android:versionName="0.8" >

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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
    <uses-permission android:name="android.permission.GET_TASKS" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >


        <activity
            android:name="com.####.#.A"
            android:label="@string/title_activity_aanmelden"
            android:screenOrientation="landscape" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.####.#.Re"
            android:label="@string/title_activity_registratie"
            android:screenOrientation="landscape" >
         </activity>

        <activity
            android:name=".KG"
            android:label="@string/title_activity_kies_gebied"
            android:screenOrientation="landscape" >
        </activity>

        <activity
            android:name=".VK"
            android:label="@string/title_activity_voorkeuren"  
            android:screenOrientation="landscape" >
        </activity>

        <receiver android:name="com.####.#.BS" >
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <receiver android:name=".COR" >
            <intent-filter>
                <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
            </intent-filter>
        </receiver>


    </application>
</manifest>

Thanks


Solution

  • I completely removed the android:theme="@style/AppTheme" attribute, now it works. Weird stuff.

    Thanks xMayank and Alec for helping.