シナリオ:ViewFlipperと2つのRelativeLayoutを含むビューlobby4.xmlがあります。両方のrelativelayoutには、buttonTOGというボタンがあり、これを使用して1つのrelativelayoutから別のrelativelayoutに切り替えることができます。コードは次のとおりです。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.lobby4);
Context context = getApplicationContext();
final ViewFlipper vf = (ViewFlipper) findViewById( R.id.viewFlipper );
bTOG=(Button)findViewById(R.id.buttonTOG);
final Activity the_a = this;
final Context static_ctx = this.getApplicationContext();
bTOG.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
String buttons=bTOG.getText().toString();
bTOG=(Button)findViewById(R.id.buttonTOG);
String mystring = getResources().getString(R.string.Playbyemail);
if( buttons!=null && buttons.compareTo(mystring)==0){
vf.showPrevious();
}else{
vf.showNext();
}
}
});
}
bTOGを2回クリックしても、onClickイベントはありません。だから私はonclickを登録する必要があると思いますか?