安卓中級教程(6):annotation的基本用法

來源:互聯網
上載者:User

標籤:

 1 package com.example.ele_me.activity; 2  3 import android.annotation.SuppressLint; 4 import android.app.Activity; 5 import android.content.Intent; 6 import android.os.Bundle; 7 import android.view.View; 8 import android.view.View.OnClickListener; 9 import android.view.Window;10 import android.widget.TextView;11 import com.example.ele_me.R;12 import com.example.ele_me.util.InjectView;13 import com.example.ele_me.util.Injector;14 15 16 //我在這裡想提及一下import 輸入了的第一個檔案是annotation,它用來反射出對象的內容,通常繼承annotation的有三個子項:17 //一個是@Override:只能用在方法之上的,用來告訴別人這一個方法是改寫父類的。18 19 //一個是@Deprecated:建議別人不要使用舊的API的時候用的,編譯的時候會用產生警告資訊,可以設定在程式裡的所有的元素上.20 21 //一個是@SuppressWarnings:這一個類型可以來暫時把一些警告資訊訊息關閉.22 23 public class WelcomeActivity extends Activity {24 @InjectView(R.id.welcome_start_order)25 private TextView start;26 @SuppressLint("NewApi")27 //以上一行是用於允許安卓的高版本相容低版本28 29 @Override30 protected void onCreate(Bundle savedInstanceState) {31 // TODO Auto-generated method stub32 super.onCreate(savedInstanceState);33 requestWindowFeature(Window.FEATURE_NO_TITLE);34 //半全螢幕35 36 setContentView(R.layout.welcome);37 Injector.get(this).inject();//init views38 start.setOnClickListener(new OnClickListener() {39 40 @Override41 public void onClick(View v) {42 Intent intent = new Intent (WelcomeActivity.this,HomePageActivity.class);    43 startActivity(intent);    44 finish();45 //一個非常容易理解的監聽器,即是只要收到有人按下button時,intent就會執行指令:從一頁跳去另一頁46 }47 });48 49 }50 51 52 }

 

安卓中級教程(6):annotation的基本用法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.