android - CursorAdapter
2018.2.21
public class MemoCursorAdapter extends CursorAdapter { public MemoCursorAdapter(Context context, Cursor cursor){ super(context,cursor,0); } @Override public View newView(Context context, Cursor cursor, ViewGroup viewGroup) { return LayoutInflater.from(context).inflate(R.layout.view_memo,viewGroup,false); } @Override public void bindView(View view, Context context, Cursor cursor) { TextView title_txt=(TextView) view.findViewById(R.id.title); String title=cursor.getString(cursor.getColumnIndexOrThrow(MySQLiteHelper.PROBLEM)); title_txt.setTypeface(Typeface.createFromAsset(context.getAssets(),"fonts/nanummyeongjo.ttf")); title_txt.setText(title); } }
저 빨간 부분을 "return LayoutInflater.from(context).inflate(R.layout.view_memo,viewGroup);"
로 잘못 쓰면
Caused by: java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
라는 에러 발생
저 메소드의 마지막 인자는 attachToRoot이다.
추론해보건대, attachToRoot를 false하지 않으면 addView메소드가 실행되는건가...?
또 그럼, attachToRoot가 false이면, addView대신 무엇이 실행되는건가..?
댓글
댓글 쓰기