gpt4 book ai didi

android - 在android中从一个屏幕导航到另一个屏幕

转载 作者:行者123 更新时间:2023-11-29 18:21:35 25 4
gpt4 key购买 nike

public class Check extends Activity implements OnClickListener {
//private check2 check2;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button usemirror = (Button)findViewById(R.id.widget28);
usemirror.setOnClickListener(this);

}
public void onClick(View view){


Intent mi = new Intent(this , check2.class);
startActivity(mi);
}
}

package com.exaple;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class check2 extends Activity {
public void onCreate(Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// setContentView(R.layout.main);

Toast.makeText(
this,
"Welcome to second page", Toast.LENGTH_LONG).show();
finish();

}

}

Android list .xml

<activity android:name=".check2" >

我这样做但没有显示我在其他 Activity 中写的消息

最佳答案

@Uttam 你没有super not called exception吗?

我想你必须在你的 check2 中调用 super.onCreate()。不在你的 check2 中调用它会导致 Force Close

public class check2 extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); //first call super.onCreate()
Toast.makeText(
this,
"Welcome to second page", Toast.LENGTH_LONG).show();
finish();

}

关于android - 在android中从一个屏幕导航到另一个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5087447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com