如何檢測圖像視圖中是否有按鈕單擊時的圖片。我有一個顯示圖片和一些結果的類,但我不希望用戶能夠訪問這些結果(按下按鈕),直到結果寫入該類。在您班級的xml文件中調用一個id
所以,我想我需要檢查是否有圖片顯示在ImageView中。
因此,像:
case R.id.previous_box:
if (R.id.photoResultView == null){
//throw up a dialog box saying they need to snap a pic first.
}
Intent j = new Intent(DTF.this, Result.class);
startActivity(j);
return;
但obviouslt R.id.photoResultView == null是不這樣做的正確方法?有誰知道怎麼樣?
坦克!
編輯:行184
if (photoResultView.getDrawable() == null) {
編輯:
case R.id.previous_box:
if (photoResultView.getDrawable() == null) {
showToast(DTF.this, "You have to take a picture first");
return;
}
Intent j = new Intent(main.this, Result.class);
startActivity(j);
return;
我把在,但它與非受迫性錯誤關閉 - 任何想法? – Sapp 2010-11-17 22:15:19
你能編輯你的LogCat輸出到你的文章嗎? – kcoppock 2010-11-17 22:17:55
photoResultView爲null,它沒有在視圖層次結構中聲明 – apps 2010-11-17 22:25:16