Android 开发:笔记应用的数据展示与活动切换
1. 笔记描述与状态处理
在处理笔记显示时,我们需要对笔记的描述和状态进行相应处理。以下是相关代码:
if(note.getDescription().length() > 15) {
holder.mDescription.setText(note.getDescription().substring(0, 15));
}
else{
holder.mDescription.setText(note.getDescription().substring(0, note.getDescription().length() /2 ));
}
// What is the status of the note?
if(note.isIdea()){
holder.mStatus.setText(R.string.idea_text);
}
else if(note.isImportant()){
holder.mStatus.setText(R.string.important_text);
}
else if(note.isTodo()){
holder.mStatus.setText(R.string.todo_text);
}
上述代码的处理逻辑如下:
|步骤|操作|
|----|----|
|1|检查笔记描述长度是否超过 15 个字符,若超过则截取前 15 个字符显示;若未超过,则截取前一半字符显示。|
|2|检查笔记的状态,根据不同状态(想法、重要、待办)设置相应
超级会员免费看
订阅专栏 解锁全文
1105

被折叠的 条评论
为什么被折叠?



