ParcelableActivity类,传递对象的Activity类。
import Android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class ParcelableActivity extends Activity {
private Button myButton;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
myButton = (Button) findViewById(R.id.myButton);
myButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
BenParcelable benParcelable = new BenParcelable("BenZeph", 23,
"Java/Android Engineer");
Intent intent = new Intent();
intent.setClass(getApplicationContext(),
GetParcelableActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable("Ben", benParcelable);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}