When i try to run the app on my phone,it force closes when i try to do activity 3. Logcat says:
01-13 17:53:25.368: E/AndroidRuntime(3235): Caused by: java.lang.NullPointerException 01-13 17:53:25.368: E/AndroidRuntime(3235): at android.app.activity3.onCreate(activity3.java:18)
第18条
Button wg = (Button) findViewById(R.id.Back);
我的《活动守则》3.java:
package android.app;
import android.app.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class activity3 extends Activity{
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main3);
Button wg = (Button) findViewById(R.id.Back);
wg.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
}
}
预 收