[Learn Android while working on projects] mobile security guard 09-mobile phone anti-theft interface setting wizard 1, android09-
This article mainly designs the wizard function interface for setting the mobile phone anti-theft interface.
Requirements:
When the user enters the mobile phone anti-theft interface, determine whether the user has performed the setting Wizard:
- If you have already set mobile phone anti-theft, you will not be prompted to enter the mobile phone wizard
- If no settings are available, you are prompted to enter the settings wizard interface.
Specific implementation:
- 1. When the user enters the correct "Mobile Phone anti-theft" password, it determines whether the user has performed the setting wizard.
/*** Determine whether the user has performed the setting Wizard * @ return */private boolean isSetup () {return sp. getBoolean ("isAlreadySetup", false );}
- 2. Create the "setting wizard" Activity and add it to the AndroidManifest. xml configuration file.
SetupWizard1Activity. java
public class SetupWizard1Activity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.setup_wizard1); }}
- 3. Add the xml layout file/mobilesafe/res/layout/setup_wizard1.xml
<style name="text_title_style"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textSize">28sp</item> <item name="android:textColor">#ff00ff66</item></style>
- . The split line under the title is frequently used. Here, the split line is abstracted.
<style name="devide_line_style"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_marginTop">8dip</item> <item name="android:layout_marginBottom">8dip</item> <item name="android:background">@drawable/devide_line</item></style>
<style name="text_content_style"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:textSize">20sp</item> <item name="android:textColor">#ff00ff66</item></style>
- 3. 4. The stars in front of the text
<style name="image_star_style"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:src">@android:drawable/btn_star_big_on</item> <item name="android:layout_marginLeft">8dip</item></style>
The image resources here use the resources provided by android. The benefits of using the image resources under @ android: 1. Reducing the size of the Program 2. Improving the program's image acquisition speed
- 3. 5. Progress display icon
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:gravity="center_horizontal" android:orientation="horizontal" > <ImageView style="@style/image_status_on_style" /> <ImageView style="@style/image_status_off_style" /> <ImageView style="@style/image_status_off_style" /><ImageView style="@style/image_status_off_style" /></LinearLayout>
<RelativeLayoutandroid: layout_width = "fill_parent" android: layout_height = "fill_parent"> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "10dip" | center_horizontal "| android: orientation =" vertical "> <ImageView android: layout_width =" wrap_content "android: layout_height =" wrap_content "android: src = "@ drawable/setup1"/> </LinearLayout> <Button android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignParentBottom = "true" android: layout_alignParentRight = "true" android: drawableRight = "@ drawable/next" android: text = "next"/> </RelativeLayout>
- 4./mobilesafe/res/layout/setup_wizard1.xml
<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "match_parent" android: layout_height = "match_parent" android: background = "@ color/background" android: orientation = "vertical"> <TextView style = "@ style/text_title_style" android: text = "1. welcome to mobile anti-theft "/> <ImageView style =" @ style/devide_line_style "/> <TextView style =" @ style/text_content_style "android: text = "your mobile phone guard can:"/> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "5dip" android: orientation = "horizontal"> <ImageView style = "@ style/image_star_style"/> <TextView style = "@ style/text_content_style" android: paddingTop = "5dip" android: text = "SIM card change alert"/> </LinearLayout> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "5dip" android: orientation = "horizontal"> <ImageView style = "@ style/image_star_style"/> <TextView style = "@ style/text_content_style" android: paddingTop = "5dip" android: text = "GPS tracking"/> </LinearLayout> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "5dip" android: orientation = "horizontal"> <ImageView style = "@ style/image_star_style"/> <TextView style = "@ style/text_content_style" android: paddingTop = "5dip" android: text = "remote data destruction"/> </LinearLayout> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "5dip" android: orientation = "horizontal"> <ImageView style = "@ style/image_star_style"/> <TextView style = "@ style/text_content_style" android: paddingTop = "5dip" android: text = "remote screen lock"/> </LinearLayout> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: layout_marginTop = "5dip" android: gravity = "center_horizontal" android: orientation = "horizontal"> <ImageView style = "@ style/image_status_on_style"/> <ImageView style = "@ style/image_status_off_style"/> <ImageView style = "@ style/image_status_off_style" /> <ImageView style = "@ style/image_status_off_style"/> </LinearLayout> <RelativeLayout android: layout_width = "fill_parent" android: layout_height = "fill_parent"> <LinearLayout android: layout_width = "fill_parent" android: layout_height = "wrap_content" android: Copyright = "10dip" android: gravity = "center_vertical | center_horizontal" android: orientation = "vertical"> <ImageView android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: src = "@ drawable/setup1"/> </LinearLayout> <Button android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_alignParentBottom = "true" android: layout_alignParentRight = "true" android: drawableRight = "@ drawable/next" android: text = "next"/> </RelativeLayout> </LinearLayout>
If (isSetup () {Log. I (TAG, "loading mobile phone anti-theft Main Interface");} else {Log. I (TAG, "activation settings wizard interface"); finish (); Intent intent = new Intent (getApplicationContext (), SetupWizard1Activity. class); startActivity (intent );}