From eab0f83048984b2e12eee3f56aa47002efe1c1d5 Mon Sep 17 00:00:00 2001 From: "KL.chh" <1679216041@qq.com> Date: Fri, 21 Apr 2023 15:04:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=88=E8=A1=A5=E5=85=85=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=BA=9B=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/micode/notes/ui/NotesListItem.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/net/micode/notes/ui/NotesListItem.java b/app/src/main/java/net/micode/notes/ui/NotesListItem.java index b6094cd..1edaec3 100644 --- a/app/src/main/java/net/micode/notes/ui/NotesListItem.java +++ b/app/src/main/java/net/micode/notes/ui/NotesListItem.java @@ -42,8 +42,14 @@ public class NotesListItem extends LinearLayout { private CheckBox mCheckBox; public NotesListItem(Context context) { - super(context); - inflate(context, R.layout.note_item, this); + super(context);/** + super()它的主要作用是调整调用父类构造函数的顺序 + */ + inflate(context, R.layout.note_item, this);/** + Inflate可用于将一个xml中定义的布局控件找出来,这里的xml是r。layout + findViewById用于从contentView中查找指定ID的View,转换出来的形式根据需要而定; + + */ mAlert = (ImageView) findViewById(R.id.iv_alert_icon); mTitle = (TextView) findViewById(R.id.tv_title); mTime = (TextView) findViewById(R.id.tv_time); @@ -59,7 +65,9 @@ public class NotesListItem extends LinearLayout { mCheckBox.setVisibility(View.GONE); } - mItemData = data; + mItemData = data;/** + 设置控件属性,一共三种情况,由data的id和父id是否与保存到文件夹的id一致来决定 + */ if (data.getId() == Notes.ID_CALL_RECORD_FOLDER) { mCallName.setVisibility(View.GONE); mAlert.setVisibility(View.VISIBLE); @@ -97,6 +105,10 @@ public class NotesListItem extends LinearLayout { } } } + + /** + * 设置内容,获取相关时间,从data里编辑的日期中获取 + */ mTime.setText(DateUtils.getRelativeTimeSpanString(data.getModifiedDate())); setBackground(data); @@ -119,6 +131,9 @@ public class NotesListItem extends LinearLayout { setBackgroundResource(NoteItemBgResources.getNoteBgNormalRes(id)); } } else { + /** + * 若不是note直接调用文件夹的背景来源 + */ setBackgroundResource(NoteItemBgResources.getFolderBgRes()); } }