0

GridLayoutにいくつかの画像ボタンのみを含む単純な Android アプリを作成しました。Eclipseで実行すると、問題やエラーは発生しませんが、エミュレーターに来ると何も表示されず、タブレットで実行するとクラッシュします。

ヒント:エミュレーターや adb にあるものではなく、他のプロジェクトは完全に実行されます。このコードを変更すると、このプロジェクトも完全に実行されるため、コードに問題があります。

更新:問題は Gridlayout にあることがわかりました。これを LinearLayout に変更したときに機能しましたが、Linear Layout が私の作業に役立たないため、Grid レイアウトにしたいのは確かです。

これは私の.xml ファイルです:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".Main" >

    <GridLayout
        android:id="@+id/grid1"
        android:layout_width="fill_parent"
        android:layout_height="500dp"
        android:layout_centerInParent="true"
        android:background="@android:color/darker_gray"
        android:columnCount="1"
        android:orientation="vertical" >

        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/homeview" />

        <ImageButton
            android:id="@+id/imageButton3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_gravity="right|top"
            android:layout_row="0"
            android:src="@drawable/profiles" />

        <ImageButton
            android:id="@+id/imageButton2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_gravity="center"
            android:layout_row="0"
            android:src="@drawable/ac" />

        <ImageButton
            android:id="@+id/imageButton5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_gravity="center"
            android:layout_row="1"
            android:src="@drawable/appliances" />

        <ImageButton
            android:id="@+id/imageButton6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_gravity="right|center_vertical"
            android:layout_row="1"
            android:src="@drawable/movies" />

        <ImageButton
            android:id="@+id/imageButton4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_column="0"
            android:layout_gravity="left|center_vertical"
            android:layout_row="1"
            android:src="@drawable/lightning" />

    </GridLayout>

 </RelativeLayout>
4

1 に答える 1

0

DDMS タブで adb をリセットします。うまくいかない場合は、コマンド プロンプトで次のコマンドを入力します。

c:\...\...\Sdk\platform-tools>adb kill-server
c:\....\...\sdk\platform-tools>adb start-server
于 2013-11-24T11:37:22.083 に答える