i am new in Android Studio, can you help me? from fragment code below, i try to compare two text which one of it is from Button, after click test_ans button, will go to 'true' activity if they are same .. but when i tried,But unfortunately the app hasis stopped if i click the button.:(
package com.xxx.xxx.xxx; import android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class Main extends AppCompatActivity { private String mAnswer = "xxx"; private Button mButtonAns; static { System.loadLibrary("native-lib"); } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final String mAnswer; final Button mButtonAns; mAnswer = "xxx"; mButtonAns = (Button)findViewById(R.id.test_ans); mButtonAns.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View view) { if (mButtonAns.getText() == mAnswer) { Intent i = new Intent(Main.this, True.class); startActivity(i); //^go to true activity } else { //go to false activity } } }); } } i tried delete @Override public void onClick(View view), the getText() become red, is that onClick is the problem? please help ;(