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 manifest.xml
<activity android:name=".check2" >
我正在这样做,但没有显示其他活动中写的信息
最佳答案
@Uttam你没有得到super not called exception
吗?
我想您必须在check2中调用super.onCreate()
。在check2中不调用会导致强制关闭
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();
}