我正在使用两个按钮。同时点击两个按钮时,它将一次进入不同的活动。如何避免这种情况?

我试过这样,但它不工作请保存….

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);

}

}

谢谢,

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐