에 글고에서 텍스트를 타고 나는이 같은 ViewHolder에 글고 치기에 포함 된 텍스트를 수행해야합니다ViewHolder 안드로이드
@Override
public void onClick(View v) {
holder.editTextComment = (EditText) v
.findViewById(R.id.editTextComment);
String comment = holder.editTextComment.getText()
.toString();
// String comment = new String("lol");
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyy");
SimpleDateFormat dt = new SimpleDateFormat("HH:mm");
String formattedDate = df.format(c.getTime());
String formattedTime = dt.format(c.getTime());
if (!comment.equalsIgnoreCase("")) {
switch (v.getId()) {
case R.id.buttonPostComment:
addItem(comment, formattedDate, formattedTime, v,
holder);
break;
}
}
하지만 내 프로그램이 충돌 내가 문자열로는 EditText 텍스트를 삽입 할 때, 왜?
logcat. 당신이 가지고있는 것을 보면서, 당신의'editTextComment'가'null'이라고 말할 것입니다. 'v.findViewById (...) '에서'v'를 제거해보십시오. – codeMagic
'getText()'를 호출하면'holder' 또는'holder.editTextComment'가 null이 될 것입니다. –
http://pastebin.com/5nrtsYuC – hasmet