开发者

Error inflating class TouchImageView

I'm trying to spruce up my image viewer activity by converting from an ImageView to a TouchImageView, per the answer here: How can I get zoom functionality for images?

However, I get an error when my activity is attempting to load:

Binary XML file line #15: Error inflating class TouchImageView

Here's my 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>

And my code inside onCreate of ImageViewer.java (though I'm pretty sure that execution never even gets this far):

    if(filepath != null && filepath.length() > 0 && new  File(filepath).exists())
    {
   开发者_StackOverflow中文版     Bitmap myBitmap = BitmapFactory.decodeFile(filepath);

        TouchImageView imgView = (TouchImageView) findViewById(R.id.imageView1); 
        imgView.setImageBitmap(myBitmap);
    }

Any ideas as to why or what is causing this error? What I saw was the inner most exception/cause. Not sure how I can get more details about the error.

Thanks in advance.

UPDATE:

Exception gets thrown on execution of this line:

setContentView(R.layout.image_viewer);

Further detail on the error:

java.lang.ClassNotFoundException: android.view.TouchImageView in loader dalvik.system.PathClassLoader@44bfde70


You need to have the fully qualified name to any custom view classes. e.g:

<com.kon.thing.TouchImageView ... />

The JVM can't find your class.


make sure u have entered a correct package name in xml like..

<com.gallery.TouchImageView
        android:id="@+id/imgDisplay"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:scaleType="fitCenter" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜