我已经从main运行一个活动。我想按下按钮,杀死这个用户界面并激活其他用户界面来完成其他工作。主要是;如何从另一个启动一个活动
in onClick (view temp)
switch(temp . getId()) {
case R.id.button_validate:
// raise other vindow after killing current one
我的其他活动类名称是renderman。我能怎么做 ?
我已经从main运行一个活动。我想按下按钮,杀死这个用户界面并激活其他用户界面来完成其他工作。主要是;如何从另一个启动一个活动
in onClick (view temp)
switch(temp . getId()) {
case R.id.button_validate:
// raise other vindow after killing current one
我的其他活动类名称是renderman。我能怎么做 ?
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId())
{
case R.id.button_validate:
Intent i=new Intent(this,renderman.class);
startActivity(i);
break;
//use multiple case(for multiple button) like this if you need
case R.id.exit_button:
finish(); //to kill current one
}
}
并添加在AndroidManifest.xml这些行..
<activity
android:name=".renderman">
</activity>
如果要启动活动把代码startActivity(new Intent(getApplicationContext(), Renderman.class))
此外,在您的清单把下面
<activity
android:name=".Renderman"
>
</activity>
</application>
你应该(但不必须)利用你的类名
的第一个字母如果你想从字面上'杀死'你的旧活动,在你开始新的活动后,用上面的代码finish()
要停止你所遇到的问题,不要
@Override
public void onBackPressed(){
//nothing, because you do not want anything to happen when you press back
}
将这个代码如下:
startActivity(new Intent(this, renderman.class));
finish();
你错过了'完成();'他暗示“正在杀死当前的一个” – Doomsknight
问题是每当我按下t按钮时他将在Android模拟器中调用第一个屏幕(从中我调用了其他用户界面)。我不想在其他活动被调用后看到第一个屏幕。我可以如何管理?如果仍然不清楚,说因为英语不是我的母语。 – gkotla
@ user1993428查看我的更新回答 – jcw