나는 recyclerview에서 편집 텍스트 편집을 마쳤을 때 notifydatasetchanged를하려고합니다 (이유는? recyclerview의 다른 객체는 액세스 할 수있는 경우에만 텍스트 편집은 "테스트"와 같습니다).안드로이드 - editify를 편집 할 때 notifyDataSetChanged
public EditTextViewHolder(View itemView, final Activity activity, final Context context, final String param) {
super(itemView);
this.activity = activity;
this.context = context;
this.param = param;
name = (TextView) itemView.findViewById(R.id.tEditTextName);
desc = (TextView) itemView.findViewById(R.id.tEditTextDescription);
details = (TextView) itemView.findViewById(R.id.tEditTextMoreDetails);
editText = (EditText) itemView.findViewById(R.id.eEditTextValue);
image = (ImageView) itemView.findViewById(R.id.iEditTextImage);
lMain = (LinearLayout) itemView.findViewById(R.id.layoutTaskEditText);
lOptional = (LinearLayout) itemView.findViewById(R.id.layoutEditTextOptional);
lRequired = (LinearLayout) itemView.findViewById(R.id.isRequiredTask);
}
public void setLayout(final Content content) {
name.setText(content.getTitle());
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
content.getAnswers().get(0).setValue(s.toString().trim());
}
});
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (!hasFocus)
TaskActivity.sAdapter.notifyDataSetChanged();
}
});
}
그러나 "RecyclerView은 레이아웃을 계산하거나 스크롤하는 동안이 방법을 호출 할 수 없습니다"나는 오류가 받고 있어요 : 그래서
내가 여기에 편집 텍스트의 하나입니다, 많은 뷰 홀더와 어댑터를 가지고 핸들러 나 UI 스레드에서 통지하려고해도 작동하지 않습니다.
내 모든 다른보기 소유자와 함께 작동합니다. 편집 텍스트로 내가 뭘 잘못하고 있는지 아십니까?
이봐, 내가 확인하기 위해 다시 한 번이 솔루션을 시도했지만 그것은 확실히 난 아직 RecyclerView 동안이 방법을 호출 할 수 없습니다 "가 작동하지 않습니다 레이아웃 또는 스크롤링을 계산하는 것입니다. " 나는 다른 파일에 많은 뷰 홀더를 가지고 있는데, 그 이유는 어댑터가 정적 인 액티비티로 내 어댑터를 얻는 이유입니다. –
더 많은 코드를 게시 할 수 있습니까? 또한 당신은 setLayout 메쏘드를 어디에서 호출 할까? –
어댑터의 onbind 함수에서 setLayout (이름이 적절하지 않을 수 있음)이 호출됩니다. 나 또한 uset getItemType –