1

Imagebutton を使用して画像を選択する必要があることをユーザーが認識できるように、Imagebutton にメッセージを表示したかったのです。

EditText.setError("Error")このタイプのメッセージを探しているメソッドを使用して表示できるエラー メッセージのタイプ。Imagebutton に表示する方法はありますか? setErrorEdittextでのみ機能します。

それとも、Google マップのマーカー スニペット メッセージのタイプですか?

警告ダイアログは大きく、大きなスペースを占有するため、使用したくありません。

4

1 に答える 1

0

これを試して:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">

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

        <TextView
            android:id="@+id/errorText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignRight="@+id/imgBt"
            android:layout_alignBottom="@+id/imgBt"
            android:background="@drawable/popup_inline_error"
            android:text="Click me first" 
            android:visibility="gone"/>

    </RelativeLayout>

Android SDK フォルダーで popup_inline_error.9.png を検索し、res/drawable フォルダーにコピーします。

onClick イベントで、エラー メッセージを表示できます。

TextView tv = (TextView) findViewById(R.id.errorText);
tv.setVisibility(View.VISIBLE);  

ここに画像の説明を入力

于 2013-10-18T14:10:13.833 に答える