im getting an error from logcat:
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)
for this piece of code. So somethings wrong with line 18*
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();
}
});
}
}
This is line 18:
wg.setOnClickListener(new View.OnClickListener() {
Thankyou!
There are two things that could be happening here:
1) You forgot to call the
setContentView()method in youronCreate()method.2) Your ID
R.id.Backdoes not exist in the XML file you loaded withsetContentView().Since you’d see an error in eclipse if the ID was bad, the most likely cause is that you forgot to call the
setContentView(R.layout.some_layout_xml_file)in theonCreate()method of your activity.