歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android中打開新的Activity的三種方法

Android中打開新的Activity的三種方法

日期:2017/3/1 10:40:01   编辑:Linux編程

Android中打開新的Activity的三種方法,平時在別人源代碼的時候經常會看到一下三種方法,剛開始不懂,現在基本了解了:

// 第一種方法:

Intent intent1 = new Intent(IntentActivity.this,

IntentSecond.class);

// 第二種方法:

Intent intent2 = new Intent();

intent2.setClass(IntentActivity.this, IntentSecond.class);

// 第三種方法:

Intent intent3 = new Intent();

intent3.setComponent(new ComponentName(IntentActivity.this,

IntentSecond.class));

startActivity(intent1);

Copyright © Linux教程網 All Rights Reserved