สร้างบันทึก
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
Google Keep API ช่วยให้คุณสร้างโน้ตได้ 2 ประเภท ได้แก่ โน้ตข้อความและโน้ตรายการ เอกสารนี้จะแสดงวิธีสร้างแต่ละประเภท
สร้างโน้ตข้อความ
ตัวอย่างต่อไปนี้แสดงวิธีสร้างหมายเหตุข้อความ
Java
/**
* Creates a new text note.
*
* @throws IOException
* @return The newly created text note.
*/
private Note createTextNote(String title, String textContent) throws IOException {
Section noteBody = new Section().setText(new TextContent().setText(textContent));
Note newNote = new Note().setTitle(title).setBody(noteBody);
return keepService.notes().create(newNote).execute();
}
สร้างโน้ตรายการ
ตัวอย่างต่อไปนี้แสดงวิธีสร้างโน้ตรายการ
Java
/**
* Creates a new list note.
*
* @throws IOException
* @return The newly created list note.
*/
private Note createListNote() throws IOException {
// Create a checked list item.
ListItem checkedListItem =
new ListItem().setText(new TextContent().setText("Send meeting invites")).setChecked(true);
// Create a list item with two children.
ListItem uncheckedListItemWithChildren =
new ListItem()
.setText(new TextContent().setText("Prepare the presentation"))
.setChecked(false)
.setChildListItems(
Arrays.asList(
new ListItem().setText(new TextContent().setText("Review metrics")),
new ListItem().setText(new TextContent().setText("Analyze sales projections")),
new ListItem().setText(new TextContent().setText("Share with leads"))));
// Creates an unchecked list item.
ListItem uncheckedListItem =
new ListItem().setText(new TextContent().setText("Send summary email")).setChecked(true);
Note newNote =
new Note()
.setTitle("Marketing review meeting")
.setBody(
new Section()
.setList(
new ListContent()
.setListItems(
Arrays.asList(
checkedListItem,
uncheckedListItemWithChildren,
uncheckedListItem))));
return keepService.notes().create(newNote).execute();
}
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-12 UTC
[null,null,["อัปเดตล่าสุด 2025-03-12 UTC"],[],[],null,["# Create notes\n\nThe Google Keep API allows you to create two types of notes: a text note and a list\nnote. This document shows how to create each type.\n\nCreate a text note\n------------------\n\nThe following sample shows how to create a text note: \n\n### REST\n\nCall [notes.create](/workspace/keep/api/reference/rest/v1/notes/create) with a\n[Note](/workspace/keep/api/reference/rest/v1/notes#Note) resource. Place the\n[TextContent](/workspace/keep/api/reference/rest/v1/notes#TextContent) in the\n[Section](/workspace/keep/api/reference/rest/v1/notes#Section) of the note.\n\n### Java\n\n /**\n * Creates a new text note.\n *\n * @throws IOException\n * @return The newly created text note.\n */\n private Note createTextNote(String title, String textContent) throws IOException {\n Section noteBody = new Section().setText(new TextContent().setText(textContent));\n Note newNote = new Note().setTitle(title).setBody(noteBody);\n\n return keepService.notes().create(newNote).execute();\n }\n\nCreate a list note\n------------------\n\nThe following sample shows how to create a list note: \n\n### REST\n\nCall [notes.create](/workspace/keep/api/reference/rest/v1/notes/list) with a\n[Note](/workspace/keep/api/reference/rest/v1/notes#Note) resource. Place the\n[ListContent](/workspace/keep/api/reference/rest/v1/notes#ListContent) in the\n[Section](/workspace/keep/api/reference/rest/v1/notes#Section) of the note.\n\n### Java\n\n /**\n * Creates a new list note.\n *\n * @throws IOException\n * @return The newly created list note.\n */\n private Note createListNote() throws IOException {\n // Create a checked list item.\n ListItem checkedListItem =\n new ListItem().setText(new TextContent().setText(\"Send meeting invites\")).setChecked(true);\n\n // Create a list item with two children.\n ListItem uncheckedListItemWithChildren =\n new ListItem()\n .setText(new TextContent().setText(\"Prepare the presentation\"))\n .setChecked(false)\n .setChildListItems(\n Arrays.asList(\n new ListItem().setText(new TextContent().setText(\"Review metrics\")),\n new ListItem().setText(new TextContent().setText(\"Analyze sales projections\")),\n new ListItem().setText(new TextContent().setText(\"Share with leads\"))));\n\n // Creates an unchecked list item.\n ListItem uncheckedListItem =\n new ListItem().setText(new TextContent().setText(\"Send summary email\")).setChecked(true);\n\n Note newNote =\n new Note()\n .setTitle(\"Marketing review meeting\")\n .setBody(\n new Section()\n .setList(\n new ListContent()\n .setListItems(\n Arrays.asList(\n checkedListItem,\n uncheckedListItemWithChildren,\n uncheckedListItem))));\n\n return keepService.notes().create(newNote).execute();\n }"]]