我在我的佈局,即兩個按鈕,如何在android中的另一個按鈕上啓用基於onclick的按鈕?
- buttonAddImage
- buttonLoadImage
現在我需要的是,我要啓用 「buttonLoadImage」 如果用戶的onclick 「buttonAddImage」 其他 「buttonLoadImage」總是禁用。如何實現這一點幫助我。
final Button buttonAddImage = (Button) findViewById(R.id.buttonAddPicture);
final Button buttonLoadImage = (Button) findViewById(R.id.buttonLoadPicture);
buttonAddImage.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
buttonLoadImage.setEnabled(true);
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Start the Intent
startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE);
}
});
什麼是與上面的代碼的問題。 – Tauqir
[如何禁用Android按鈕?]的可能重複(http://stackoverflow.com/questions/4384890/how-to-disable-an-android-button) –
上述代碼在onclick後顯示「buttonLoadImage」 「buttonAddImage」工作正常..但我想禁用「buttonLoadImage」如果用戶不點擊「buttonAddImage」。 –