在标记上方显示用户名

时间:2016-07-24 07:02:15

标签: android google-maps google-maps-api-3 firebase infowindow

我创建了一个Android应用,可以显示保存在Firebase中的其他用户位置,然后在Google地图中显示用户标记。我成功地显示了用户的图片,以及用户名like this picture of my screenshot of my apps的“名称”标题 但现在我很难显示用户与他们的照片及其位置匹配的名称。

如何显示用户名称,就像我在其位置标记上方显示用户的个人资料图片一样?我想在Firebase中显示基于用户名的存储数据

这是我在CustomInfoWindowAdapter.java中的代码

public class CustomInfoWindowAdapter implements GoogleMap.InfoWindowAdapter {

private View mymarkerview;
private Context context;

private Application app;
private Marker marker;
private Firebase ref;
private AuthData authData;
private String orig_display_name;
private TextView mDisplayName;

public CustomInfoWindowAdapter(Context context_given) {
    context = context_given;
    app = (Application) context;
}

public View getInfoWindow(Marker marker) {

    // PIN Marker.
    if (marker.getAlpha() == (float) .99) { return null; }

    // User Location Marker:
    LayoutInflater inflater = LayoutInflater.from(context);
    mymarkerview = inflater.inflate(R.layout.custom_info_window, null);
    this.marker = marker;
    render();
    return mymarkerview;
}

public View getInfoContents(Marker marker) {
    return null;
}

private void render() {

    if (!marker.getTitle().equals("")) {
        ImageView image_disp = (ImageView) mymarkerview.findViewById(R.id.indiv_pro_pic);
        image_disp.setImageBitmap(Application.decodeBase64(marker.getTitle()));

        TextView mDisplayName = (TextView) mymarkerview.findViewById(R.id.txtName);
        orig_display_name = ("Username");
        mDisplayName.setText(orig_display_name);
        }
    }

}

这适用于custom_info_window.xml布局

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

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/indiv_pro_pic"
        android:layout_gravity="center_horizontal"
        android:scaleType="fitXY"
        android:src="@drawable/unknownuser" />

    <TextView android:id="@+id/txtName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center_vertical"
        android:layout_alignParentTop="true"
        android:layout_alignParentBottom="true"
        android:textStyle="bold"
        android:textSize="22dp"
        android:text="Nama User"
        android:textColor="#000000"
        android:layout_gravity="center" />

</LinearLayout>

0 个答案:

没有答案