I'm trying to create a simple button that opens to a different activity:
package com.example.xxx.buttonexample;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.view.View;
import android.view.View.OnClickListener;
public class MainActivity extends Activity {
Button button;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btnClick();
}
public void btnClick() {
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
Intent intent = new Intent(this,emergencyIntent.class);
startActivity(intent);
}
});
}
}
Here is my emergencyIntent.class file:
package com.example.xxx.buttonexample;
import android.app.Activity;
import android.os.Bundle;
public class emergencyIntent extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// The activity is being created.
}
}
I received a error:
"Cannot resolve constructor 'intent(anonymous android.view.View.OnClickListener, java.lang.Class(com.example.xxx.buttonexample.emergencyIntent))'.