public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EditText text = (EditText)findViewById(R.id.editText1);
EditText text1 = (EditText)findViewById(R.id.editText2);
String userid = text.getText().toString();
String pass = text1.getText().toString();
Toast.makeText(getBaseContext(),"Entered"+userid+"and password entered is"+pass,Toast.LENGTH_SHORT).show();
}
});
}
The code runs successfully, but nothing happens when the button is clicked. When I focus on the line in eclipse, it says the following
"The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new
View.OnClickListener(){}, String, int)"
Please tell me what I need to do to make it work.
source
share