https://codeasy.tistory.com/27?category=751342 해당 링크에서 따라하기 글을 작성하며 따라해봤는데요.
memo하는 XML파일이 없어서 질문합니당..
어떻게구성을해야할지...
MemoActivity 내용입니다.
MemoActivity를 작동할 activity_memo가 없습니다..
public class MemoActivity extends AppCompatActivity{
int year, month, date;
String memo;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_memo);
Intent intent = getIntent();
if (intent != null) {
Calendar calendar = Calendar.getInstance();
year = intent.getIntExtra("year", calendar.get(Calendar.YEAR));
month = intent.getIntExtra("month", calendar.get(Calendar.MONTH));
date = intent.getIntExtra("date", calendar.get(Calendar.DATE));
memo = intent.getStringExtra("memo");
if (!TextUtils.isEmpty(memo))
etMemo.setText(memo);
}
Memo memo = new Memo();
memo.setYear(year);
memo.setMonth(month);
memo.setDate(date);
memo.setMemo(etMemo.getText().toString());
}
@OnClick(R.id.memo_save)
public void onClickSave() {
Calendar calendar = Calendar.getInstance();
Memo memo = new Memo();
memo.setYear(calendar.get(Calendar.YEAR));
memo.setMonth(calendar.get(Calendar.MONTH)+1);
memo.setDate(calendar.get(Calendar.DATE));
memo.setMemo(etMemo.getText().toString());
Realm realm = Realm.getDefaultInstance();
realm.beginTransaction();
realm.copyToRealm(memo);
realm.commitTransaction();
realm.close();
finish();
}
public static Intent newIntent(Context context, int year, int month, int date, String memo) {
Intent intent = new Intent(context, MemoActivity.class);
intent.putExtra("year", year);
intent.putExtra("month", month);
intent.putExtra("date", date);
intent.putExtra("memo", memo);
return intent;
}
}