我試圖通過從ImageView的轉換爲TouchImageView,每個答案這裏來美化我的圖像瀏覽器的活動:How can I get zoom functionality for images?錯誤充氣類TouchImageView
不過,我得到當我的活動試圖加載錯誤:
Binary XML file line #15: Error inflating class TouchImageView
這裏是我的image_viewer.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
<WebView
android:id="@+id/webView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
-->
<TouchImageView
android:id="@+id/imageView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
而且我的代碼裏面ImageViewer.java的的onCreate(雖然我敢肯定,執行甚至從來沒有得到這一步):
if(filepath != null && filepath.length() > 0 && new File(filepath).exists())
{
Bitmap myBitmap = BitmapFactory.decodeFile(filepath);
TouchImageView imgView = (TouchImageView) findViewById(R.id.imageView1);
imgView.setImageBitmap(myBitmap);
}
任何想法,爲什麼或什麼原因造成這個錯誤?我所看到的是最內在的異常/原因。不知道如何獲得有關錯誤的更多詳細信息。
在此先感謝。
UPDATE:
異常被扔在這條線的執行:
setContentView(R.layout.image_viewer);
更多細節上的錯誤:
java.lang.ClassNotFoundException: android.view.TouchImageView in loader [email protected]
是你的整個XML文件?它說第15行,但是那裏的行比那裏少。另外 - 如果可以的話,嘗試在eclipse中進入調試模式,並在onCreate的開始處插入一個斷點,然後逐步瀏覽,看看你得到了多少。 – Martyn
我刪除了註釋掉的代碼。我會把它重新放回去,以求準確。 :) – Kon
並添加更新的錯誤信息。 – Kon