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?
Your AndroidManifest.xml should have
Because Switch widget supports 14 and above API level only..
A simple example for you..