Android简单笔记本解析(1),真的已经讲烂了

添加搜索(NoteList–onOptionsItemSelected方法)

case R.id.menu_search:

Intent intent = new Intent();

intent.setClass(NotesList.this,NoteSearch.class);

NotesList.this.startActivity(intent);

return true;

布局搜索页面(note_search_list.xml)

SearchView和ListView分别用来实现搜索功能和显示搜索出来的条目

<?xml version="1.0" encoding="utf-8"?>

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

android:orientation=“vertical”

android:layout_width=“match_parent”

android:layout_height=“match_parent”>

<SearchView

android:id=“@+id/search_view”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”

android:iconifiedByDefault=“false”

android:queryHint=“输入搜索内容…”

android:layout_alignParentTop=“true”>

<ListView

android:id=“@android:id/list”

android:layout_width=“match_parent”

android:layout_height=“wrap_content”>

查询按钮的监听器、查询列表的监听器以及查询界面的初始化(NoteSearch)

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 = 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”>
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Android工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则近万的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Android移动开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

img

img

img

img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Android开发知识点,真正体系化!

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!

如果你觉得这些内容对你有帮助,可以扫码获取!!(备注:Android)

尾声

在我的博客上很多朋友都在给我留言,需要一些系统的面试高频题目。之前说过我的复习范围无非是个人技术博客还有整理的笔记,考虑到笔记是手写版不利于保存,所以打算重新整理并放到网上,时间原因这里先列出面试问题,题解详见:


展示学习笔记

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

ps://img2.imgtp.com/2024/03/13/H4lCoPEF.jpg" />

尾声

在我的博客上很多朋友都在给我留言,需要一些系统的面试高频题目。之前说过我的复习范围无非是个人技术博客还有整理的笔记,考虑到笔记是手写版不利于保存,所以打算重新整理并放到网上,时间原因这里先列出面试问题,题解详见:

[外链图片转存中…(img-1kyQoqFl-1712437316303)]
展示学习笔记
[外链图片转存中…(img-mSLNOlD3-1712437316303)]
[外链图片转存中…(img-xGhvmlKM-1712437316303)]

《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取!

  • 23
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值