2

この膨張した XML を返すInfoWindowAdapterを実装しました

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/layoutRoot"
    android:clickable="true">

    <TextView
        android:id="@+id/titleText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:text="Medium Text"
        android:textStyle="bold"
        android:textAppearance="?android:attr/textAppearanceMedium" />

    <TextView
        android:id="@+id/snippetText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Medium Text"
        android:gravity="center"
        android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

によって膨らませられる

public class MarkerWindowProvider implements InfoWindowAdapter {
    private LayoutInflater lInflater;
    private InfoWindowClickListener onClick;
    
    public MarkerWindowProvider(Context parent, InfoWindowClickListener onClick) {
        lInflater = (LayoutInflater) parent.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.onClick = onClick;
    }
    
    @Override
    public View getInfoContents(Marker marker) {
        return null;
    }

    @Override
    public View getInfoWindow(final Marker marker) {
        View contents = lInflater.inflate(R.layout.custom_infowindow, null);
        ((TextView)contents.findViewById(R.id.titleText)).setText(marker.getTitle());
        ((TextView)contents.findViewById(R.id.snippetText)).setText(marker.getTitle());
        contents.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                onClick.onClick(marker);
            }
        });
        return contents;
    }
    
    public interface InfoWindowClickListener {
        public void onClick(Marker marker);
    }
}

株式情報ウィンドウの代わりに膨張したレイアウトが表示されますが、XML を膨張させるために選択したメソッドに関係なく、OnClick メソッドは起動しません。

私は本当にこの機能が必要です。なぜこれが機能しないのかについてのアイデアはありますか? 代替案はありますか?ありがとう。

4

1 に答える 1