Android多个button只点一个,如何在android中同时避免多个按钮点击?
我正在使用两个按钮。同时点击两个按钮时,它将一次进入不同的活动。如何避免这种情况?我试过这样,但它不工作请保存….public class MenuPricipalScreen extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceStat
我正在使用两个按钮。同时点击两个按钮时,它将一次进入不同的活动。如何避免这种情况?
我试过这样,但它不工作请保存….
public class MenuPricipalScreen extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu_principal_layout);
findViewById(R.id.imageView2).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
disable(findViewById(R.id.imageView3));
Intent intent = new Intent(MenuPricipalScreen.this,
SelectYourLanguageVideo.class);
startActivity(intent);
}
});
findViewById(R.id.imageView3).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
disable(findViewById(R.id.imageView2));
Intent intent = new Intent(MenuPricipalScreen.this,
CategoryScreen.class);
intent.putExtra("request", "false");
startActivity(intent);
}
});
}
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
((ImageView) findViewById(R.id.imageView3)).setEnabled(true);
((ImageView) findViewById(R.id.imageView2)).setEnabled(true);
((ImageView) findViewById(R.id.imageView3)).setClickable(true);
((ImageView) findViewById(R.id.imageView2)).setClickable(true);
((ImageView) findViewById(R.id.imageView3)).setFocusable(true);
((ImageView) findViewById(R.id.imageView2)).setFocusable(true);
}
private void disable(View v) {
Log.d("TAG", "TAG" + v.getId());
v.setEnabled(false);
v.setClickable(false);
v.setFocusable(false);
}
}
谢谢,
更多推荐
所有评论(0)