I am trying to create a simple button that opens for another action:
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);
I got an error message:
"Cannot resolve constructor" (anonymous android.view.View.OnClickListener, java.lang.Class (com.example.xxx.buttonexample.emergencyIntent)).
source share