作者ETspace (我是外星人)
看板AndroidDev
标题[问题] setview无法正常换页
时间Wed Oct 12 04:28:25 2011
我的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
1F:推 LaPass:Log中有错误讯息吗? 10/12 18:29
2F:推 milochen:不如先独立,把 next.class 上的 Activity run起来如何? 10/14 21:06
3F:推 king5201:查查看next class 里面呼叫的layout有没有问题 10/17 00:42