我在地图上工作我创建了一个地图屏幕并使用marker.markers创建了Info Window Adapter的帮助。在信息窗口适配器我有textview名称,卷号和地址我想设置点击事件的名称,地址。你能告诉我这是怎么做到的。如何在InfoWindowAdapter中设置点击事件
package com.ihealthhome.ui;
import java.util.Hashtable;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.maps.GoogleMap.InfoWindowAdapter;
import com.google.android.gms.maps.model.Marker;
import com.ihealthhome.R;
import com.ihealthhome.dataparser.ClientsDetailDAO;
import com.ihealthhome.listeners.ClientDetailNavigationListener;
/**
* @author DotZoo Inc, created on 02-Jan-2014
*/
public class CustomInfoWindowAdapter implements InfoWindowAdapter {
private View view;
Context ctx;
private Hashtable<String, ClientsDetailDAO> renderMarker;
public CustomInfoWindowAdapter(Context ctx,
Hashtable<String, ClientsDetailDAO> markers) {
this.ctx = ctx;
this.renderMarker = markers;
view = ((Activity) ctx).getLayoutInflater().inflate(
R.layout.custom_infowindow, null);
}
@Override
public View getInfoContents(Marker marker) {
return null;
}
@Override
public View getInfoWindow(Marker marker) {
final ImageView profileImage = (ImageView) view
.findViewById(R.id.userProfile);
TextView clientName = ((TextView) view.findViewById(R.id.clientName));
final TextView clientCellPhone = ((TextView) view
.findViewById(R.id.clientCellPhone));
final TextView clientHomePhone = ((TextView) view
.findViewById(R.id.clientHomePhone));
final TextView clientWorkPhone = ((TextView) view
.findViewById(R.id.clientWorkPhone));
final TextView clientDashboard = ((TextView) view
.findViewById(R.id.clientDashboard));
final ClientsDetailDAO info = renderMarker.get(marker.getId());
String firstName = info.getFirstName();
String lastname = info.getLastName();
if (!TextUtils.isEmpty(firstName) && !TextUtils.isEmpty(lastname)) {
clientName.setText(new StringBuilder(firstName).append(" ").append(
lastname));
}
String cellPhone = info.getCellPhone();
if (cellPhone != null && !TextUtils.isEmpty(cellPhone)) {
clientCellPhone.setText(cellPhone);
}
String homePhone = info.getHomePhone();
if (homePhone != null && !TextUtils.isEmpty(homePhone)) {
clientHomePhone.setText(homePhone);
}
String workPhone = info.getWorkPhone();
if (workPhone != null && !TextUtils.isEmpty(workPhone)) {
clientWorkPhone.setText(workPhone);
}
clientName.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(ctx, "on click", Toast.LENGTH_LONG).show();
mClientDetailListener.gotoClientDetail(info.getClientID(),
info.getFirstName());
}
});
return view;
}
ClientDetailNavigationListener mClientDetailListener;
public void setNavigateToClientDetailListener(
ClientDetailNavigationListener mClientDetailListener) {
this.mClientDetailListener = mClientDetailListener;
}
}
尝试将每个视图单击侦听器实现为clientName。 – 2014-10-30 10:33:43
你能解释一下吗? – aditay 2014-10-30 10:39:07
当你点击到名字不等时,你想做什么? – 2014-10-30 10:56:17