2

このような

ここに画像の説明を入力

ボタンをクリックするとメニューがドロップダウンします。以前ListViewは実装していたのですが、3 点ボタンの取り付け方とポップアップ メニューの追加方法がわかりません。

これが私のlist_item.xmlです

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginBottom="4dp"
        android:layout_marginLeft="6dp"
        android:layout_marginRight="6dp"
        android:layout_marginTop="4dp"
        android:background="@drawable/card_background" >

        <TextView
            android:id="@+id/tvMain"
            android:layout_width="0dip"
            android:layout_height="wrap_content"
            android:layout_gravity="left|center_vertical"
            android:layout_weight="1"
            android:textColor="@android:color/primary_text_light" />
    </LinearLayout>

</FrameLayout>

そして、私のアプリのスクリーンショット:

https://www.dropbox.com/s/h2ko2ctfn5ohmf9/Screenshot_2013-09-10-15-43-57.png

4

1 に答える 1

0

これImageViewは、正しい PNG を使用したものであり (Photoshop、ペイント、GIMP、またはその他のグラフィカル エディターで自分で画像を描画する必要があります)、PopupWindowを使用してポップアップを作成します。

PopupWindow を実行する方法の簡単な例を次に示します (ここから取得しますhttp://android-er.blogspot.de/2012/03/example-of-using-popupwindow.html )

@Override
public void onClick(View view) {
LayoutInflater layoutInflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);  
View popupView = layoutInflater.inflate(R.layout.popup, null);
final PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);  
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
btnDismiss.setOnClickListener(new Button.OnClickListener(){
    @Override
    public void onClick(View v) {
        popupWindow.dismiss();
    }});
popupWindow.showAsDropDown(view, 0, -0);

}

于 2013-09-10T08:15:29.300 に答える