`
deepfuture
  • 浏览: 4428938 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:80295
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:70785
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:103945
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:287426
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:15120
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:68275
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:32527
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:46244
社区版块
存档分类
最新评论

android-notepad学习

阅读更多

新建一个android project,选择create project from exsting sample

然后 选择NotePad,打开后可以看到该程序的文件


 

1.根包名称定义:com.example.android.notepad

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.android.notepad"
>

2.入口activity

当要求运行android应用程序时,主机会加载该应用程序并读取androidmanifest.xml文件,然后使用其中的intent过滤器查找并启动一个或多少activity,这个intent过滤器具有main操作和launcher类别

 

NotesList定义了几个intet过滤器,其中定义了一个具有main操作和launcher类别的过滤器,意味着Notelist是属于应用程序启动时运行的活动。

  <activity android:name="NotesList" android:label="@string/title_notes_list">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <action android:name="android.intent.action.PICK" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.GET_CONTENT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>
        </activity>

 

3.其它active定义

1)NoteEditor

        <activity android:name="NoteEditor"
            android:theme="@android:style/Theme.Light"
            android:label="@string/title_note"
            android:screenOrientation="sensor"
            android:configChanges="keyboardHidden|orientation"
        >
            <!-- This filter says that we can view or edit the data of
                 a single note -->
            <intent-filter android:label="@string/resolve_edit">
                <action android:name="android.intent.action.VIEW" />
                <action android:name="android.intent.action.EDIT" />
                <action android:name="com.android.notepad.action.EDIT_NOTE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>

            <!-- This filter says that we can create a new note inside
                 of a directory of notes. -->
            <intent-filter>
                <action android:name="android.intent.action.INSERT" />
                <category android:name="android.intent.category.DEFAULT" />
                <data android:mimeType="vnd.android.cursor.dir/vnd.google.note" />
            </intent-filter>

        </activity>

2)TitleEditor

     <activity android:name="TitleEditor"
            android:label="@string/title_edit_title"
            android:theme="@android:style/Theme.Dialog"
            android:windowSoftInputMode="stateVisible">
            <!-- This activity implements an alternative action that can be
                 performed on notes: editing their title.  It can be used as
                 a default operation if the user invokes this action, and is
                 available as an alternative action for any note data. -->
            <intent-filter android:label="@string/resolve_title">
                <!-- This is the action we perform.  It is a custom action we
                     define for our application, not a generic VIEW or EDIT
                     action since we are not a general note viewer/editor. -->
                <action android:name="com.android.notepad.action.EDIT_TITLE" />
                <!-- DEFAULT: execute if being directly invoked. -->
                <category android:name="android.intent.category.DEFAULT" />
                <!-- ALTERNATIVE: show as an alternative action when the user is
                     working with this type of data. -->
                <category android:name="android.intent.category.ALTERNATIVE" />
                <!-- SELECTED_ALTERNATIVE: show as an alternative action the user
                     can perform when selecting this type of data. -->
                <category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
                <!-- This is the data type we operate on. -->
                <data android:mimeType="vnd.android.cursor.item/vnd.google.note" />
            </intent-filter>
        </activity>

3)NotesLiveFolder

        <activity android:name="NotesLiveFolder" android:label="@string/live_folder_name"
            android:icon="@drawable/live_folder_notes">
            <intent-filter>
                <action android:name="android.intent.action.CREATE_LIVE_FOLDER" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

4)NoteList的oncreate方法

  protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);

        // If no data was given in the intent (because we were started
        // as a MAIN activity), then use our default content provider.
        Intent intent = getIntent();
        if (intent.getData() == null) {
            intent.setData(Notes.CONTENT_URI);
        }

        // Inform the list we provide context menus for items
        getListView().setOnCreateContextMenuListener(this);
       
        // Perform a managed query. The Activity will handle closing and requerying the cursor
        // when needed.
        Cursor cursor = managedQuery(getIntent().getData(), PROJECTION, null, null,
                Notes.DEFAULT_SORT_ORDER);

        // Used to map notes entries from the database to views
        SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.noteslist_item, cursor,
                new String[] { Notes.TITLE }, new int[] { android.R.id.text1 });
        setListAdapter(adapter);
    }

  • 大小: 20.1 KB
分享到:
评论

相关推荐

    android练习-notePad

    【标题】"Android练习-notePad" 是一个针对Android平台的简单笔记应用的开发实践项目,旨在帮助开发者加深对Android编程的理解和应用。这个项目可能是基于一个基础的记事本应用程序,提供基本的文本编辑和存储功能,...

    android-notepad-app:记事本应用

    【标题】"android-notepad-app:记事本应用"是一个基于Android平台的简单记事本应用程序,它允许用户创建、编辑和保存文本笔记。在Android开发中,这样的应用是学习和理解基本Android组件、数据存储以及用户界面设计...

    android-notepad4taxi:Android应用程式只是为了锻炼

    "android-notepad4taxi"项目就是一个专门为初学者设计的练习平台,它基于Google的Notepad教程进行改编,旨在帮助开发者熟悉Android开发的基本概念和流程。 在Android开发中,Java语言是最常用的语言之一,因此这个...

    安卓开发-NotePad.zip

    在Android开发中,NotePad经常被用作初学者学习和练习的基本项目,因为它涉及到常见的应用程序功能,如数据存储、用户界面设计和交互等。下面我们将深入探讨这个主题,详细讲解安卓应用开发中的关键知识点。 1. **...

    android入门Notepad+源代码.rar

    这个"android入门Notepad+源代码.rar"就是一个很好的学习资源,其中包含了详细的中文注释,非常适合中文环境下的初学者。 1. Android Studio环境配置与项目导入 在开始之前,确保你已经安装了Android Studio,这是...

    Android-Notepad-App:作为德克萨斯大学达拉斯分校用户界面课程的一部分创建的 Android 记事本应用程序

    对于初学者而言,这是一个极好的学习资源,能够帮助他们理解Android应用开发的全貌。而对于经验丰富的开发者,这个项目则提供了一个实践和优化用户界面设计的平台。通过深入研究和实践,开发者可以提升自己的技能,...

    kotlin-notepad:项目测试Kotlin-Notepad udacity

    "Kotlin-Notepad" 是一个基于 Kotlin 语言的记事本应用程序项目,用于测试和学习 Kotlin 的编程技能。"udacity" 指的是 Udacity 这个在线教育平台,该平台提供了许多编程课程,包括 Kotlin 课程。这个项目可能就是 ...

    Notepad++ 插件,AndroidLogger.V1.2.7. 可以让安卓日志自动显示颜色

    此外,压缩包中的AndroidLogger.src.zip文件包含了插件的源代码,如果你对插件的工作原理感兴趣,或者想要进行二次开发,这是一个很好的学习资源。 Config文件夹可能包含了插件的配置文件或默认设置,这取决于插件...

    Android 4.0 Notepad 源代码

    Android 4.0 Notepad 源代码是一个深入理解Android应用程序开发的重要实例,特别是对于那些想要学习或增强在Android平台上构建简单文本编辑器应用技能的人来说。这个源代码提供了Android 4.0 Ice Cream Sandwich ...

    Android NotePad便签-IT计算机-毕业设计.zip

    本篇文章将深入探讨"Android NotePad便签"这个源码Demo,它是一个基础的Android笔记应用实例,非常适合初学者学习和作为毕业设计参考。 一、Android应用的基本结构 "NotePad便签"项目展示了标准的Android应用结构,...

    2011.09.23——— android sample之Notepad(context menu)

    标题中的“2011.09.23——— android sample之Notepad(context ...通过学习这个示例项目,开发者不仅可以掌握上下文菜单的实现,还能了解到Android应用开发的多个核心概念和技术,为自己的Android开发技能树添砖加瓦。

    Android记事本notepad源代码

    "Android记事本notepad源代码"是一个适合初学者实践的项目,它展示了如何构建一个简单的记事本应用。 首先,我们需要了解Android应用程序的基本结构。一个Android项目通常包含以下几个主要部分: 1. **...

    journal-notepad

    《构建Android日记应用:以"journal-notepad"为例》 在移动设备的众多应用中,日记类应用...开发者可以通过学习和分析这个项目,提升自己的Android开发技能,同时也能理解如何构建一个实用且用户体验良好的日记应用。

    android版的notepad的源码

    在Android平台上,Notepad是一款非常基础的记事本应用,它的源码对于初学者和开发者来说,是一个很好的学习资源。这个源码可以帮助我们理解Android应用的基本结构、UI设计、数据存储以及事件处理等核心概念。 1. **...

    Text-to-Speech-Notepad:Android应用程序使用文本到语音引擎将文本保存在文件中并说出内容

    《构建Android应用:Text-to-Speech-Notepad的深度解析》 在当今信息化社会,文本与语音之间的转换已经成为日常生活中不可或缺的一部分。Text-to-Speech (TTS) 技术允许我们将书面文字转化为可听见的声音,极大地...

    Notepad-master.zip

    《Android Studio开发的便签应用——Notepad》 在Android应用程序开发领域,Notepad-master.zip是一个包含源代码的压缩包,它提供了一个基于...对这个项目的学习和实践可以帮助开发者提升Android应用开发的技能。

    android SDK 下 NotePad例子详解

    通过分析NotePad这个例子,开发者不仅可以学习到Android的基本编程技巧,还能深入理解Android应用的架构和组件之间的交互方式。这对于初学者来说是一个很好的起点,而对于有经验的开发者来说,也可以作为复习和巩固...

    android NotePad便签源码.rar

    【描述】"android NotePad便签源码.rar"包含了完整的Android NotePad应用源代码,适用于初学者或有经验的开发者进行研究和学习。通过分析和理解这个源码,可以深入理解Android应用的生命周期、数据库操作、UI布局...

    android notePad solution 源码

    【标题】:“Android NotePad Solution 源码分析” 在这个教程中,我们将深入探讨一个名为“NotePad”的Android应用程序的源代码。这个源码实例来源于Android开发者官方教程,旨在帮助开发者理解如何在Android平台...

    Notepad android 记事本 源码

    这对于进一步学习和开发更复杂的Android应用具有基础性的作用。在实际项目中,这些基础知识依然广泛应用于现代的Android应用开发中,虽然工具和SDK版本已发生了变化,但核心原理和实践依然有效。

Global site tag (gtag.js) - Google Analytics