如何从EditText设置标记标题

时间:2014-09-19 06:55:48

标签: android google-maps android-edittext google-maps-markers

我使用此代码..

@Override
public void onMapLongClick(final LatLng point) {
   LayoutInflater layoutInflater = LayoutInflater.from(MainActivity.this);  // Get the layout inflater
   dialogView = layoutInflater.inflate(R.layout.custom, null);
   AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
   builder.setTitle("New Marker");
   builder.setView(dialogView);      
   //Inflate and set the layout for the dialog
   editText_markerTitle = (EditText) dialogView.findViewById(R.id.editText_custom);
   //editText_markerTitle.requestFocus();
   markerTitle = editText_markerTitle.getText().toString();
   ..................so on
}
builder.show();

和drawMarker func as:

public void drawMarker(LatLng point){
marker = googleMap.addMarker(new MarkerOptions()
.title(editText_markerTitle.getText().toString())
.position(point));
}

问题在于,当我首先运行应用程序时,它会从editText_markerTitle perfectley获取标题并在infowindow中显示标题。但是当我再次运行应用程序时。应用程序崩溃。不知道是什么问题。

0 个答案:

没有答案