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();
}
});
}
代码成功执行,但按下按钮时没有任何反应。当我专注于 eclipse 中的线条时,它会说以下内容
"The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (new
View.OnClickListener(){}, String, int)"
请告诉我我需要做什么才能使它工作