public class NoteSearch extends ListActivity implements

SearchView.OnQueryTextListener {

private static final String[] PROJECTION = new String[] {

NotePad.Notes._ID, // 0

NotePad.Notes.COLUMN_NAME_TITLE, // 1

//扩展 显示时间 颜色

NotePad.Notes.COLUMN_NAME_MODIFICATION_DATE // 2

//NotePad.Notes.COLUMN_NAME_BACK_COLOR

};

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.note_search_list);

Intent intent = getIntent();

if (intent.getData()

== null) {

intent.setData(NotePad.Notes.CONTENT_URI);

}

SearchView searchview =

(SearchView)findViewById(R.id.search_view);

//为查询文本框注册监听器

searchview.setOnQueryTextListener(NoteSearch.this);

}

@Override

public boolean onQueryTextSubmit(String query) {

return false;

}

@Override

public boolean onQueryTextChange(String newText) {

String selection = NotePad.Notes.COLUMN_NAME_TITLE + " Like ? ";

String[] selectionArgs = { “%”+newText+"%" };

Cursor cursor = managedQuery(

getIntent().getData(), PROJECTION,

selection, selectionArgs, NotePad.Notes.DEFAULT_SORT_ORDER

);

String[] dataColumns = {

NotePad.Notes.COLUMN_NAME_TITLE

, NotePad.Notes.COLUMN_NAME_MODIFICATION_DATE };

int[]

viewIDs = { android.R.id.text1

, R.id.text1_time };

SimpleCursorAdapter adapter = new SimpleCursorAdapter(

this,

R.layout.noteslist_item,

cursor,

dataColumns,

viewIDs

);

setListAdapter(adapter);

return true;

}

@Override

protected void onListItemClick(ListView l, View v, int position, long

id) {

Uri uri = ContentUris.withAppendedId(getIntent().getData(),

id);

String action

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享

= getIntent().getAction();

if (Intent.ACTION_PICK.equals(action)

|| Intent.ACTION_GET_CONTENT.equals(action)) {

setResult(RESULT_OK, new Intent().setData(uri));

} else {

startActivity(new Intent(Intent.ACTION_EDIT, uri));

}

}

}

3.时间戳的实现


在文本下方显示时间

文本标题(noteslist_item.xml)

<TextView xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@android:id/text1"

android:layout_width=“match_parent”

android:layout_height="?android:attr/listPreferredItemHeight"

android:textAppearance="?android:attr/textAppearanceLarge"

android:gravity=“center_vertical”

android:paddingLeft=“5dip”

android:singleLine=“true”

/>

我们要在标题下方添加时间,那么可以再写一个时间的TextView,把标题和时间的TextView放入垂直线性布局内就好了

<LinearLayout xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@+id/layout"

android:layout_width=“match_parent”

android:layout_height=“match_parent”

android:orientation=“vertical”>

<TextView xmlns:android=“http://schemas.android.com/apk/res/android”

android:id="@android:id/text1"

android:layout_width=“match_parent”

android:layout_height="?android:attr/listPreferredItemHeight"

android:textAppearance="?android:attr/textAppearanceLarge"

android:gravity=“center_vertical”

android:paddingLeft=“5dip”

android:singleLine=“true”

/>

<TextView

android:id="@+id/text1_time"

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:textAppearance="?android:attr/textAppearanceSmall"

android:text="@string/text_title"

android:paddingLeft=“5dip”

/>

在数据库中存放时间(NotePadProvider)

public void onCreate(SQLiteDatabase db) {

db.execSQL(“CREATE TABLE " + NotePad.Notes.TABLE_NAME + " (”

  • NotePad.Notes._ID + " INTEGER PRIMARY KEY,"

  • NotePad.Notes.COLUMN_NAME_TITLE + " TEXT,"

  • NotePad.Notes.COLUMN_NAME_NOTE + " TEXT,"

  • NotePad.Notes.COLUMN_NAME_CREATE_DATE + " INTEGER,"

  • NotePad.Notes.COLUMN_NAME_MODIFICATION_DATE + " INTEGER"

  • “);”);

}

通过Cursor从数据库中读取出

Cursor cursor = managedQuery(

getIntent().getData(), // Use the default content URI for the provider.

PROJECTION, // Return the note ID and title for each note.

null, // No where clause, return all records.

null, // No where clause, therefore no where column values.

NotePad.Notes.DEFAULT_SORT_ORDER // Use the default sort order.

);

通过SimpleCursorAdapter装填

String[] dataColumns = { NotePad.Notes.COLUMN_NAME_TITLE } ;

int[] viewIDs = { android.R.id.text1 };

SimpleCursorAdapter adapter

= new SimpleCursorAdapter(

this, // The Context for the ListView

Android简单笔记本解析,成功入职头条月薪35K相关推荐

  1. 阿里P8亲自讲解!成功入职头条月薪35K

    前言 又到一年金九银十之际. Java作为目前用户最多,使用范围最广的软件开发技术之一. Java的技术体系主要由支撑Java程序运行的虚拟机,提供各开发领域接口支持的Java,Java编程语言及许多 ...

  2. 看完直接怼项目经理!成功入职网易月薪35K,原理+实战讲解

    前言 Netty 是一款基于 Java 的网络编程框架,能为应用程序管理复杂的网络编程.多线程处理以及并发.Netty 隐藏了样板和底层代码,让业务逻辑保持分离,更加易于复用.使用 Netty 可以得 ...

  3. 安卓屏幕完美适配方案,成功入职网易月薪35K

    2.分辨率: 手机在横向.纵向上的像素点数总和,一般描述成 宽*高 , 即横向像素点个数*纵向像素点个数. 3.屏幕尺寸(in): 手机对角线的物理尺寸,单位 英寸(inch),一英寸大约2.54cm ...

  4. 开发者必备的顶级Android开发工具,成功入职阿里

    前言 近日,字节跳动正式启动了2021届秋季校园招聘,为应届毕业生开放超过6000个工作岗位.这一数字超过了该公司往年秋招规模,并与其今年春招规模持平.全年校招人数共计超过1万2千人,远高于同类型互联 ...

  5. 开发8年的老Android才知道,成功入职腾讯

    前言 现在已经进入招聘季节,本篇文章旨在分享知名互联网企业面试官面试方法和心得,希望通过本文的阅读能给程序员带来不一样的面试体验和感受,放松面试心态,积极备战! Android 知识体系 在 Andr ...

  6. 真香定律!一文带你搞懂Android多线程Handler,成功入职腾讯

    Google 为了帮助 Android 开发者更快更好地开发 App,推出了一系列组件,这些组件被打包成了一个整体,称作 Android Jetpack,它包含的组件如下图所示: 老的 support ...

  7. android培训技能!一眼就能看懂的Android自学手册,成功入职字节跳动

    背景 曾经有人问我,为什么要下班了不找点乐子,还花这么多时间去写一份资料.你是不是傻! 我无言以对! 但是不得不说,这份笔记确实倾注了我很多心血. 至于,我为什么要做这份资料,为什么又要写这篇文章!是 ...

  8. 网易云的朋友给我这份339页的Android面经,成功入职阿里

    IT行业的前景 近几年来,大数据.人工智能AI.物联网等一些技术不断发展,也让人们看到了IT行业的繁荣与良好的前景.越来越多的高校学府加大了对计算机的投入,设立相应的热门专业来吸引招生.当然也有越来越 ...

  9. 已成功入职字节月薪20k,2022最新软件测试面试题《含答案》

    随着企业对于软件质量的重视,软件测试工程师倍受青睐,对于求职者的要求也在提高,不仅要求求职者具备扎实的理论功底,还要有丰富的实战经验,这就给软件测试工程师求职增加了难度.今天就给大家分享一些常见的软件 ...

最新文章

  1. java 模式匹配算法_用Java匹配模式
  2. 菲律宾谋定农业大建特建构想 对话国际农民丰收节贸易会
  3. Winform中实现根据配置文件重新加载ZedGraph属性的实现思路
  4. Windows组策略完善主机安全整改实战(1)
  5. 【常见笔试面试算法题12续集四】动态规划算法案例分析4 LCS练习题练习题(最长公共子序列的长度)
  6. java webservice 服务器_java如何写webservice服务端
  7. shell检查硬盘分区空间
  8. Storm,Spark和Samza
  9. 1000道Python题库系列分享一(17道)
  10. python数据结构list的extend与append的差别
  11. myeclipse 安装svn(subeclipsesite)插件
  12. 什么是磁力链接如何愉快的使用磁力链接
  13. 闭环控制 matlab仿真,反馈闭环控制系统Simulink仿真(带电流补偿的电压内环,直流调速)...
  14. 折半查找的实现 swustoj
  15. pyqt5使用pyinstaller打包项目为exe
  16. 历时两年,从刚毕业的软通动力到现在的字节跳动,我的经验全在这里了
  17. stm32波特率配置
  18. 俄方产量也将削减恐左右油价未来走势
  19. 无法启动此程序因为计算机丢失gdiplus,处理系统提示无法启动此程序,因为计算机中丢失gdiplus.dll的方法...
  20. 自己动手写个微型 CSDN 吧,还能实现网页版 Blink,No.1

热门文章

  1. 使用ts-node去支持TS的Node运行环境
  2. unity 手机重力迷宫(四)
  3. 头歌平台Docker企业级实训 第2章 Docker进阶之镜像 镜像管理
  4. axios再次封装,axios拦截器
  5. jQuery 的jaxa请求;
  6. JcJc错别字在线检查工具: 网络小说错别字在线检查工具
  7. tplink 2.4g弱信号剔除_如何区分2.4G和5G路由器之间的区别?2.4G和5G路由器那个更好?...
  8. 新手程序员想兼职却没有渠道?来看资深程序员在哪接单!
  9. 15个受用一生的学习习惯
  10. 产品经理如何才能很好的进行跨部门协作?