2013-03-01 63 views
0

这里是我在谷歌地图android api v2中添加标记的代码。 我的问题是我不能从我的EditText片段获取字符串值。代码.getText()。toString()不能获取字符串值,只能发送null。 请帮帮我。.getText()。toString()给出NullPointerException

+0

认沽XML文件! – 2013-03-01 06:50:44

回答

0

添加以下代码

onMapLongClick()

LayoutInflater inflater = (LayoutInflater) context 
        .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View rowView = inflater.inflate(R.layout.alertlayout, parent, false); 
0

你得到空指针,因为你没有实现getter和setter为编辑文本值,您需要按照这个..

  1. 正确膨胀你的布局..

    LayoutInflater mInflater =(LayoutInflater)context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); 
    

    convertView = mInflater.inflate(R.layout.alertlayout,null);

2.Crate ViewHolder类包含该编辑文本的getter和setter。

  1. convertView.setTag(holder);

  2. 创建像holder = (ViewHolder) convertView.getTag(); 持有者对象,现在你可以得到holder.get....();

相关问题