【邊做項目邊學Android】手機安全衛士09-手機防盜介面設定嚮導1,android09-

來源:互聯網
上載者:User

【邊做項目邊學Android】手機安全衛士09-手機防盜介面設定嚮導1,android09-

本次主要做手機防盜介面的設定嚮導功能介面的設計。

需求:

當使用者進入手機防盜介面時,判斷使用者是否已經進行過設定嚮導:

  • 如果使用者已經設定過手機防盜,則不再提示使用者進入手機嚮導
  • 若還沒有設定,則提示使用者進入設定嚮導介面。
具體實現:
  • 1.當使用者輸入“手機防盜”密碼正確時,進行判斷使用者是否進行過設定嚮導
/** * 判斷使用者是否進行過設定嚮導 * @return */private boolean isSetup(){    return sp.getBoolean("isAlreadySetup", false);}
  • 2.建立“設定嚮導”的Activity,並添加到AndroidManifest.xml資訊清單檔中

SetupWizard1Activity.java

public class SetupWizard1Activity extends Activity {    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.setup_wizard1);    }}
  • 3.添加xml布局檔案/mobilesafe/res/layout/setup_wizard1.xml
    • 3.1.由於每個嚮導介面的標題文字樣式都是統一的,因此可以將標題文字樣式抽取出來:

      • /mobilesafe/res/values/style.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>
    • 3.2.標題下面的分割線 因為後面要經常使用,此處也是將分割線抽象出來。
<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>
    • 3.3.本文內容樣式
<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.文字前的小星星
<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>

此處的圖片資源使用了android內建的資源,使用@android下的圖片資源的好處: 1. 減少程式的體積 2. 提高程式擷取圖片的速度

    • 3.5.進度顯示表徵圖
<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>
    • 3.5.表徵圖以及“下一步”
<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="下一步" /></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. 歡迎使用手機防盜" />    <ImageView style="@style/devide_line_style" />    <TextView        style="@style/text_content_style"        android:text="您的手機防盜衛士可以:" />    <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卡變更警示" />    </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追蹤" />    </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="遠程銷毀資料" />    </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="遠程鎖屏" />    </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:layout_marginTop="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="下一步" />    </RelativeLayout></LinearLayout>
  • 5.介面跳轉
if(isSetup()){Log.i(TAG, "載入手機防盜主介面");}else{Log.i(TAG, "啟用設定嚮導介面");finish();Intent intent = new Intent(getApplicationContext(), SetupWizard1Activity.class);startActivity(intent);}
  • 6.顯示效果

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.