[問題] setview無法正常換頁
我的manifest已有設定
我是做一個按了按鈕後會跳出一個讓使用者輸入文字的視窗
文字輸入完畢按確認,就會跳到另一個頁面
因為彈跳的視窗要讓使用者輸入,因此我是採取寫一個xml檔
然後利用setview讀取
本頁檔名為now,本頁中有個b1按鈕,按下後會跳出確認視窗
視窗檔名為go
欲跳頁面檔名為next
視窗跟欲跳頁面的java檔都只有這樣的設置
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.next);//或R.layout.go
沒有其他設定
---------------------------程式碼如下--------------------------------
setContentView(R.layout.main);
Button button=(Button)findViewById(R.id.b1);
button.setOnClickListener(openDialog);
private OnClickListener openDialog=new OnClickListener(){
@Override
public void onClick(View v) {
Insert();
}};
public void Insert() {
LayoutInflater factory=LayoutInflater.from(now.this);
final View v1=factory.inflate(R.layout.go,null);
AlertDialog.Builder dialog=new AlertDialog.Builder(now.this);
dialog.setTitle("確認身分");
dialog.setView(v1);
dialog.setPositiveButton("確認", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
//登入後跳到另一個頁面
Intent intent = new Intent();
intent.setClass(now.this,next.class);
now.this.startActivity(intent);
}});
------------------------------------------------------------------------------
黃字的部分,如果我是now.this,now.class就會成功
但如果要跳到非本頁,就會強制關閉程式
請問是setview後無法跳到其他頁面,還是我邏輯上有問題呢~"~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.34.44.193
推
10/12 18:29, , 1F
10/12 18:29, 1F
推
10/14 21:06, , 2F
10/14 21:06, 2F
推
10/17 00:42, , 3F
10/17 00:42, 3F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章