我正在构建一个简单的日志应用程序,用户可以用它来做笔记。我正在尝试从活动中的数据库中获取期刊列表。当我得到它时,它会显示用户输入的整个笔记。我只想获取第一行单词,以便用户可以单击它以获取完整注释。这是我的代码
这是我将代码保存到数据库的地方
private void saveNoteToDB(View v) {
Note note = new Note();
String newNotes = enterNotes.getText().toString();
note.setTheNotes(newNotes);
//Save to Db
db.addNotes(note);
Snackbar.make(v, "Note Saved", Snackbar.LENGTH_LONG).show();
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
alertDialog.dismiss();
startActivity(new Intent(ListNotes.this, ListNotes.class));
}
}, 1500);
}
这是我从数据库中获取项目的地方
//Get notes from Database
noteItem = db.getAllNotes();
for (Note c : noteItem) {
Note note = new Note();
note.setTheNotes(c.getTheNotes());
note.setId(c.getId());
note.setDateNotesAdded(c.getDateNotesAdded());
listItem.add(note);
}
recyclerViewAdapter = new RecyclerViewAdapter(this, listItem);
recyclerView.setAdapter(recyclerViewAdapter);
recyclerViewAdapter.notifyDataSetChanged();
}
倚天杖
不负相思意
相关分类