2010-04-21 44 views
0

时,我有一个崩溃(应用程序意外停止)这个main.xml中的问题是一个“HelloWorld”的类型项目(同时测试和学习功能,我需要为我的应用程序):Android的崩溃调用的ImageButton

我隔离作为的ImageButton一个问题,但我不能排除任何参数...

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <ImageButton android:id="@+id/picture"  
    android:layout_width="240dip"  
    android:layout_height="180dip" 
    android:layout_gravity="center_horizontal" 
    android:src="@drawable/icon" 
    android:adjustViewBounds="true"  
    android:cropToPadding="true"  
    android:clickable="true"  
    android:scaleType="fitCenter" />  

</LinearLayout> 

的icon.png在我的资源存在...... 我可以看到预览的布局选项卡,即使图像没有集中在按钮上,但我读到这是正常的。

下面的代码工作正常(作为一个常规的按钮)。我也可以像ImageView那样做。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <Button android:id="@+id/picture" 
    android:layout_width="240dip" 
    android:layout_height="180dip" 
    android:layout_gravity="center_horizontal" /> 

</LinearLayout> 

我使用Eclipse和AVD,和我所有的学习是在2.1(SDK 7级)来完成。 我无法在实际设备上测试应用程序,因为我还没有。

在此先感谢!

+1

您需要在Eclipse中从LogCat视图中发布Java堆栈跟踪。 – 2010-04-21 18:25:03

回答

2

哦,麻烦了! 似乎这是我的MyApp.java中的一个java错误,当我试图声明该按钮的事件时。案件结案。抱歉。