0

私は Java/Eclipse の経験はかなりありますが、Android 開発はまったくの初心者であり、これまでのところ非常に奇妙な獣であることが証明されています。現在、2 つの画像ボタンを持つアプリケーションを作成しようとしています。私のXMLは次のとおりです。

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

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="24dp"
        android:text="@string/now_playing" />

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageButton
            android:id="@+id/StartButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/start_button"
            android:contentDescription="@string/start_button" />

        <ImageButton
            android:id="@+id/StopButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@drawable/stop_button"
            android:contentDescription="@string/stop_button" />

    </LinearLayout>

</LinearLayout>

これは正しいように見えますが、[グラフィカル レイアウト] タブで ImageButtons が適切にレンダリングされず、「次のクラスが見つかりませんでした: - ImageButton (android.widget.ImageButton に変更し、ビルド パスを修正し、 XML を編集する)".

オンラインで少し調べたところ、StackOverflow でこの質問が何度か表示されていることがわかりましたが、満足のいく答えは見つかりませんでした。最も一般的な答えは、プロジェクトをきれいにすることでしたが、これは私には何もしませんでした. 助言がありますか?

4

2 に答える 2

0

Java で ImageButton クラスをインポートしてみてください。

import android.widget.ImageButton;
于 2019-02-07T19:36:58.377 に答える