我正在制作一个具有以下布局的应用程序:主应用程序布局在应用程序中,我使用“拍照”按钮从手机调用相机意图来拍照。图片被显示到图像视图中(在布局中以红色勾勒)。
我还使用保存按钮通过意图将图片保存到图库。我还使用签名按钮来捕获用户的签名。签名有自己的布局。布局包括以下内容:签名布局但是,假设我打开应用程序并在当前没有显示图像时点击保存按钮。尽管没有图片,我的保存按钮目前仍然可以使用并拉出图库。我的签名布局中的保存按钮也会发生同样的事情。如果当前没有签名,保存按钮仍然保存。
我将如何将其编码到可以检查当前是否已显示图片或已显示签名的位置,如果没有,则禁用我的签名和主应用程序布局中的保存按钮。我知道禁用按钮的语法是:myButton.setEnabled(false);
我在主应用程序布局中的保存按钮有以下代码:
//this save button is for the gallery app after you take a photo
saveButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
//launch the gallery app intent
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setType("image/*");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Toast.makeText(DriverActivity.this, "Image Saved to Gallery", Toast.LENGTH_SHORT).show();
/*if there is currently no image, disable save button and display a toast message
Toast.makeText(DriverActivity.this, "There's no image currently shown.", Toast.LENGTH_SHORT).show();*/
}
});
// restoring storage image path from saved instance state
// otherwise the path will be null on device rotation
restoreFromBundle(savedInstanceState);
慕斯709654
料青山看我应如是
相关分类