編輯:關於android開發
使用intent啟動activity
/**
* Serializeable傳遞對象的方法
*/
private void SerializeMethod(){
Person mPerson = new Person();
mPerson.setName("andy");
mPerson.setAge(26);
Intent mIntent = new Intent(this,SerializableDemo.class);
Bundle mBundle = new Bundle();
mBundle.putSerializable(SER_KEY,mPerson);
mIntent.putExtras(mBundle);
startActivity(mIntent);
}
/**
* Pacelable傳遞對象方法
*/
private void PacelableMethod(){
Police mPolice = new Police();
mPolice.setName("I am Police");
mPolice.setWorkTime(2008);
Intent mIntent = new Intent(this,ParcelableDemo.class);
Bundle mBundle = new Bundle();
mBundle.putParcelable(PAR_KEY, mPolice);
mIntent.putExtras(mBundle);
startActivity(mIntent);
}
接收
public class SerializableDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView mTextView = new TextView(this);
Person mPerson = (Person)getIntent().getSerializableExtra(TestActivity.SER_KEY);
mTextView.setText("You name is: " + mPerson.getName() + "/n"+
"You age is: " + mPerson.getAge());
setContentView(mTextView);
}
}
public class ParcelableDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView mTextView = new TextView(this);
Police mPolice = (Police)getIntent().getParcelableExtra(TestActivity.PAR_KEY);
mTextView.setText("Police name is: " + mPolice.getName()+"/n"+
"WorkTime is: " + mPolice.getWorkTime() + "/n");
setContentView(mTextView);
}
}
Android快樂貪吃蛇游戲實戰項目開發教程-06虛擬方向鍵(五)繪制方向鍵箭頭,android-06本系列教程概述與目錄:http://www.cnblogs.com/
android滾動公告欄,android公告欄項目裡要用到開獎公告,單行顯示向上滾動的TextView,網上隨便找了一個控件發現效果還不錯改裝一下就可以用到項目裡。唯一不
Android開發Tips(2) 1. Dagger2的開發順序 Module -> Component -> Application 首先模塊(Modul
完美高仿精仿京東商城手機客戶端android版源碼,高仿精android完美高仿精仿京東商城手機客戶端android版源碼,喜歡的朋友可以下載吧。 源