单击某些图像按钮并执行某些操作时,我正在调用函数 click() 。
public void onClick(View v)
{
switch (v.getId()) {
case R.id.btn_first_person:
Log.i("utc","1st person");
this.flip(R.id.btn_i);
this.flip(R.id.btn_we);
break;
case R.id.btn_i:
Log.i("utc","I clicked");
this.change("I","play");
break;
case R.id.btn_we:
Log.i("utc","We clicked");
this.change("We","plays");
break;
default: Log.i("utc","default");
Log.i("utc","asa" + v.getId());
}
}
“btn_i”按钮工作正常,但是当我点击“btn_we”按钮时,它直接进入默认状态。不知道为什么??
public void change(String person, String verb)
{
txtUsageFirst=(TextView)findViewById(R.id.utc_usage_one);
txtUsageSecond=(TextView)findViewById(R.id.utc_usage_two);
txtUsageFirst.setText(person);
txtUsageSecond.setText(verb);
}
同样,当我在第一种情况下调用此翻转函数时 (btn_first_person) 发生错误,在 btnTemp=(Button) findviewbyid(r); 行 [logcat 不显示 "check","1" ]
public void flip(Integer r)
{
Log.d("check","enetred flip");
Log.d("check",r.toString());
btnTemp=(Button) findViewById(r);
Log.d("check","1");
if(btnTemp.getVisibility()== View.VISIBLE)
{
Log.d("check","invisible now");
btnTemp.setVisibility(View.GONE);
}
else
{
Log.d("check","visible now");
btnTemp.setVisibility(View.VISIBLE);
}
}