I have a crash (Application Stopped Unexpectedly) problem with this main.xml is a "HelloWorld" type project (while testing and learning features I need for my app) :
I isolated the ImageButton as an issue, but I can't isolate any of the parameters...
<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 exists in my resources... I can see the preview in the Layout tab, even though the image is not centered on the button, but I read that it was normal.
The code below works fine (as a regular Button). I can also do the same as an 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>
I use Eclipse and the AVD, and all my learning is done on 2.1 (SDK level 7). I can't test the app on an actual device yet as I don't have it yet.
Thanks in advance !
Oh bother !! It seems that it was a java error in my MyApp.java, when I was trying to declare the event for the button. Case closed. Sorry.
精彩评论