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 = 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));
}
}
}
在文本下方显示时间
文本标题(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"
-
“);”);
}
最后
答应大伙的备战金三银四,大厂面试真题来啦!
这份资料我从春招开始,就会将各博客、论坛。网站上等优质的Android开发中高级面试题收集起来,然后全网寻找最优的解答方案。每一道面试题都是百分百的大厂面经真题+最优解答。包知识脉络 + 诸多细节。
节省大家在网上搜索资料的时间来学习,也可以分享给身边好友一起学习。
《960全网最全Android开发笔记》
《379页Android开发面试宝典》
包含了腾讯、百度、小米、阿里、乐视、美团、58、猎豹、360、新浪、搜狐等一线互联网公司面试被问到的题目。熟悉本文中列出的知识点会大大增加通过前两轮技术面试的几率。
如何使用它?
1.可以通过目录索引直接翻看需要的知识点,查漏补缺。
2.五角星数表示面试问到的频率,代表重要推荐指数
《507页Android开发相关源码解析》
只要是程序员,不管是Java还是Android,如果不去阅读源码,只看API文档,那就只是停留于皮毛,这对我们知识体系的建立和完备以及实战技术的提升都是不利的。
真正最能锻炼能力的便是直接去阅读源码,不仅限于阅读各大系统源码,还包括各种优秀的开源库。
腾讯、字节跳动、阿里、百度等BAT大厂 2020-2021面试真题解析
资料收集不易,如果大家喜欢这篇文章,或者对你有帮助不妨多多点赞转发关注哦。文章会持续更新的。绝对干货!!!
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
mjxDEIwg-1714211449455)]
腾讯、字节跳动、阿里、百度等BAT大厂 2020-2021面试真题解析
[外链图片转存中…(img-zg6bkOeR-1714211449455)]
资料收集不易,如果大家喜欢这篇文章,或者对你有帮助不妨多多点赞转发关注哦。文章会持续更新的。绝对干货!!!
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!