我正在尝试获取EditText
命名组件中的文本textfield
,看看它是否等于“facebook”。但它不起作用,我无法终生找出原因。同样在 if 语句my
中应该是图片的 ID。
public class Guess extends Activity {
ImageView image;
ImageView stat;
Button okButton;
EditText textfield;
Integer my;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.guess);
final Bundle bundle = this.getIntent().getExtras();
int pic = bundle.getInt("myimage");
final int resid = bundle.getInt("resourceID");
my = pic;
image = (ImageView) findViewById(R.id.imageView1);
image.setImageResource(pic);
image.setAdjustViewBounds(true);
stat = (ImageView) findViewById(R.id.imageView2);
stat.setImageResource(R.drawable.incorrect);
okButton = (Button) findViewById(R.id.button1);
okButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
textfield = (EditText) findViewById(R.id.editText1);
if("2130837510".equals(my.toString()) && "facebook".equals(textfield.getText()));
{
stat.setImageResource(R.drawable.correct);
}
}
});
}
}