我試圖誇大捕獲異常膨脹的佈局
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Item android:id="@+id/ltArr"
android:layout_alignParentLeft="true"
android:icon="@android:drawable/arrow_up_float"/>
<TextView android:id="@+id/ImText"
android:layout_toRightOf="@id/ltArr"/>
<Item android:layout_alignParentRight="true"
android:layout_toRightOf="@id/ImText"
android:icon="@android:drawable/arrow_down_float"/>
</RelativeLayout>
在我打電話addTextView一個過程,它是在一個try catch塊
try{
addTextView("Showtext", intID, addtothisLayout);
}catch (Exception ex){}
當addText充氣上述佈局程序中有一個異常被捕獲,執行被回送到調用程序中的捕獲
void addTextView(String showTxt,integer id, ViewGroup addtoparent)
{
View itemview = View.inflate(this, R.layout.itemlayout, addtoparent); //this causes the exception
..
..
}
爲什麼當拋出異常時,我不能在ex變量中看到任何東西?
我在想什麼傻事?
如何查看異常情況?我試圖檢查異常ex變量作爲調試器通過它,但它沒有任何東西。如果我在過程中使用SQL。我特意拋出SQLException,這將允許我看到錯誤描述,但在這裏我不知道要拋出什麼......?
我發現通過刪除try catch子句引用了LogCat中不存在的資源異常。但是,如何在try ex中捕獲這些描述?我必須拋出特定的例外嗎?
好的,這是我的答案,我試圖檢查變量的聲明,並需要在代碼塊中放置一些東西。 「ex.toString()」
catch (Exception ex){
ex.toString();
}
感謝所有非常迅速的答覆。
相對佈局缺少關閉'>' – Chopin 2012-04-28 21:57:27
「拋出異常」:有[Logcat](http://www.droidnova.com/debugging-in-android-using-eclipse,541.html)和如果您將錯誤追加到您的問題中,應該可以找到答案。 – zapl 2012-04-28 21:58:06
錯字,生病修復 – Kickaha 2012-04-28 21:59:09