From 3364c862ebe3f9feff3c093a8382996b1fe25df4 Mon Sep 17 00:00:00 2001 From: rtc Date: Wed, 20 Dec 2023 23:25:09 +0800 Subject: [PATCH] Signed-off-by: rtc --- .../micode/notes/ui/FoldersListAdapter.java | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/Notes-master/src/net/micode/notes/ui/FoldersListAdapter.java b/src/Notes-master/src/net/micode/notes/ui/FoldersListAdapter.java index 96b77da..e661ca5 100644 --- a/src/Notes-master/src/net/micode/notes/ui/FoldersListAdapter.java +++ b/src/Notes-master/src/net/micode/notes/ui/FoldersListAdapter.java @@ -1,19 +1,3 @@ -/* - * Copyright (c) 2010-2011, The MiCode Open Source Community (www.micode.net) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - package net.micode.notes.ui; import android.content.Context; @@ -28,11 +12,10 @@ import net.micode.notes.R; import net.micode.notes.data.Notes; import net.micode.notes.data.Notes.NoteColumns; - public class FoldersListAdapter extends CursorAdapter { public static final String [] PROJECTION = { - NoteColumns.ID, - NoteColumns.SNIPPET + NoteColumns.ID, + NoteColumns.SNIPPET }; public static final int ID_COLUMN = 0; @@ -45,12 +28,14 @@ public class FoldersListAdapter extends CursorAdapter { @Override public View newView(Context context, Cursor cursor, ViewGroup parent) { + // 创建新的列表项的视图 return new FolderListItem(context); } @Override public void bindView(View view, Context context, Cursor cursor) { if (view instanceof FolderListItem) { + // 判断视图类型是否为FolderListItem,如果是,则获取文件夹的名称并绑定到视图上 String folderName = (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context .getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN); ((FolderListItem) view).bind(folderName); @@ -58,6 +43,7 @@ public class FoldersListAdapter extends CursorAdapter { } public String getFolderName(Context context, int position) { + // 获取指定位置的文件夹名称 Cursor cursor = (Cursor) getItem(position); return (cursor.getLong(ID_COLUMN) == Notes.ID_ROOT_FOLDER) ? context .getString(R.string.menu_move_parent_folder) : cursor.getString(NAME_COLUMN); @@ -68,13 +54,14 @@ public class FoldersListAdapter extends CursorAdapter { public FolderListItem(Context context) { super(context); + // 填充布局文件到当前视图中 inflate(context, R.layout.folder_list_item, this); mName = (TextView) findViewById(R.id.tv_folder_name); } public void bind(String name) { + // 将文件夹名称绑定到视图上 mName.setText(name); } } - -} +} \ No newline at end of file