I want to create a button which, when clicked, it will show another intent.
This is the code:
<Button android:text="Bine ati venit!" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/button1" android:background="#479fc7" android:textSize="40dp" android:textColor="@color/colorPrimaryDark" android:textStyle="normal|bold|italic" android:textAllCaps="false" android:fontFamily="casual" android:onClick="next_page"/>
and from the .java class:
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); } Button button = (Button) findViewById(R.id.button1); button.setOnClickListener( new View.OnClickListener() { public void onClick (View v){ next_page(v); } }); public void next_page(View v) { Intent intent = new Intent(this, MapsActivity.class); startActivity(intent); }
I get the errors: “Cannot resolve symbol ‘setOnClickListener'”, “variable onClick is never used”, “; expected”….