例如:從第壹個活動跳轉到第二個活動的代碼:
如果FristActivity和SecondActivity對應的UI是FristAty.xml和SecondAty.xml,則有:
(1)在FristActivity.xml中添加壹個按鈕
(2)用FristActivity編寫以下主要代碼:
公開課活躍拓展活動{
Button BTN =(Button)findViewById(r . id . Button);
btn.setOnClickListener(新視圖。OnClickListener() {
@覆蓋
公共void onClick(視圖視圖){
Intent Intent = new Intent(frist activity . this,second activity . class);
startActivity(意圖);
}
});
}