Android实现记事本功能(26)

本文实例为大家分享了Android实现记事本功能的具体代码,供大家参考,具体内容如下

MainActivity.java代码:

package siso.smartnotef.activity;

import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import siso.smartnotef.R;
import siso.smartnotef.adapter.NotepadeAdapter;
import siso.smartnotef.db.DataHelper;
import siso.smartnotef.global.GlobalParams;
import siso.smartnotef.model.NotepadBean;
import siso.smartnotef.model.NotepadWithDataBean;
import siso.smartnotef.service.MainService;

public class MainActivity extends AppCompatActivity implements View.OnClickListener, NotepadeAdapter.ClickFunction {

 private TextView tv_add;
 private ListView lv_contents;
 private List<NotepadWithDataBean> notepadWithDataBeanList;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  Intent intent1 = new Intent(MainActivity.this, MainService.class);
  startService(intent1);
  findViews();
  setListeners();
  initView();

 }

 private void findViews() {
  tv_add = (TextView) findViewById(R.id.tv_add);
  lv_contents = (ListView) findViewById(R.id.lv_content);
 }

 private void setListeners() {
  tv_add.setOnClickListener(this);
 }

 private void initView() {
  DataHelper helper = new DataHelper(MainActivity.this);
  notepadWithDataBeanList = new ArrayList<NotepadWithDataBean>();
  List<NotepadBean> notepadBeanList = helper.getNotepadList();
  for (int i = 0; i < notepadBeanList.size(); i++) {
   if (0 == notepadWithDataBeanList.size()) {
    NotepadWithDataBean notepadWithDataBean = new NotepadWithDataBean();
    notepadWithDataBean.setData(notepadBeanList.get(0).getDate());
    notepadWithDataBeanList.add(notepadWithDataBean);
   }
   boolean flag = true;
   for (int j = 0; j < notepadWithDataBeanList.size(); j++) {
    int date = notepadWithDataBeanList.get(j).getData();
    if (date == notepadBeanList.get(i).getDate()) {
     notepadWithDataBeanList.get(j).getNotepadBeenList().add(notepadBeanList.get(i));
     flag = false;
     break;
    }
   }
   if (flag) {
    NotepadWithDataBean notepadWithDataBean = new NotepadWithDataBean();
    notepadWithDataBean.setData(notepadBeanList.get(i).getDate());
    notepadWithDataBeanList.add(notepadWithDataBean);
    notepadWithDataBeanList.get(notepadWithDataBeanList.size() - 1).getNotepadBeenList().add(notepadBeanList.get(i));
   }
  }
  NotepadeAdapter adapter = new NotepadeAdapter(MainActivity.this, notepadWithDataBeanList, this);
  lv_contents.setAdapter(adapter);
//  setListViewHeightBasedOnChildren(lv_contents);
 }

 public void setListViewHeightBasedOnChildren(ListView listView) {
  if (listView == null) return;
  ListAdapter listAdapter = listView.getAdapter();
  if (listAdapter == null) {
   // pre-condition
   return;
  }
  int totalHeight = 0;
  for (int i = 0; i < listAdapter.getCount(); i++) {
   View listItem = listAdapter.getView(i, null, listView);
   listItem.measure(0, 0);
   totalHeight += listItem.getMeasuredHeight();
  }
  ViewGroup.LayoutParams params = listView.getLayoutParams();
  params.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1));
  listView.setLayoutParams(params);
 }

 @Override
 public void onClick(View v) {
  switch (v.getId()) {
   case R.id.tv_add:
    Intent intent = new Intent();
    Bundle bundle = new Bundle();
    bundle.putInt(GlobalParams.TYPE_KEY, GlobalParams.TYPE_ADD);
    intent.putExtras(bundle);
    intent.setClass(MainActivity.this, AddContentActivity.class);
    startActivityForResult(intent, GlobalParams.ADD_REQUEST);
    break;
  }
 }

 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  switch (requestCode) {
   case GlobalParams.ADD_REQUEST:
    if (GlobalParams.ADD_RESULT_OK == resultCode) {
     initView();
    }
    break;
  }
 }

 @Override
 public void clickItem(int position, int itemPosition) {
  Bundle bundle = new Bundle();
  bundle.putInt(GlobalParams.TYPE_KEY, GlobalParams.TYPE_EDIT);
  bundle.putSerializable(GlobalParams.BEAN_KEY, notepadWithDataBeanList.get(position));
  bundle.putInt(GlobalParams.ITEM_POSITION_KEY, itemPosition);
  Intent intent = new Intent(this, AddContentActivity.class);
  intent.putExtras(bundle);
  startActivityForResult(intent, GlobalParams.ADD_REQUEST);
 }

 @Override
 public void longClickItem(final int position, final int itemPostion) {
  AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
  builder.setMessage("确认删除吗?");
  builder.setTitle("提示");
  builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
    DataHelper helper = new DataHelper(MainActivity.this);
    helper.deleteNotepad(notepadWithDataBeanList.get(position).getNotepadBeenList().get(itemPostion).getId());
    initView();
   }
  });
  builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
   @Override
   public void onClick(DialogInterface dialog, int which) {
    dialog.dismiss();
   }
  });
  builder.create().show();
 }
}

AddContentActivity.java代码:

package siso.smartnotef.activity;

import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;

import java.util.Calendar;

import siso.smartnotef.R;
import siso.smartnotef.db.DataHelper;
import siso.smartnotef.global.GlobalParams;
import siso.smartnotef.model.NotepadBean;
import siso.smartnotef.model.NotepadWithDataBean;

public class AddContentActivity extends AppCompatActivity implements View.OnClickListener {

 private TextView tv_save;
 private TextView tv_date;
 private TextView tv_time;
 private TextView tv_cancel;
 private EditText et_content;
 private String time = "";
 private String date = "";
 private Bundle bundle;
 private int type;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_add_content);
  bundle=getIntent().getExtras();
  type=bundle.getInt(GlobalParams.TYPE_KEY);
  findViews();
  setListeners();
  initDate();
 }

 private void findViews() {
  et_content=(EditText)findViewById(R.id.et_content);
  tv_save = (TextView) findViewById(R.id.tv_save);
  tv_date = (TextView) findViewById(R.id.tv_date);
  tv_time = (TextView) findViewById(R.id.tv_time);
  tv_cancel=(TextView)findViewById(R.id.tv_cancel);
 }

 private void setListeners() {
  tv_save.setOnClickListener(this);
  tv_date.setOnClickListener(this);
  tv_time.setOnClickListener(this);
  tv_cancel.setOnClickListener(this);
 }

 private void initDate() {
  Calendar c = Calendar.getInstance();
  int year=c.get(Calendar.YEAR);
  int month=c.get(Calendar.MONTH);
  int day=c.get(Calendar.DAY_OF_MONTH);
  date=getDate(year,month,day);
  if(type==GlobalParams.TYPE_EDIT){
   NotepadWithDataBean notepadWithDataBean=(NotepadWithDataBean)(bundle.getSerializable(GlobalParams.BEAN_KEY));
   et_content.setText(notepadWithDataBean.getNotepadBeenList().get(bundle.getInt(GlobalParams.ITEM_POSITION_KEY)).getContent());
   date=notepadWithDataBean.getData()+"";
   tv_date.setText(date);
   time=notepadWithDataBean.getNotepadBeenList().get(bundle.getInt(GlobalParams.ITEM_POSITION_KEY)).getTime();
   tv_time.setText(time);
  }
 }

 private String getDate(int year,int month,int day){
  String date="";
  date+=year;
  if(month<9){
   date=date+"0"+(month+1);
  }else{
   date+=(month+1);
  }
  if(day<10){
   date=date+"0"+day;
  }else {
   date+=day;
  }
  return date;
 }
 @Override
 public void onClick(View v) {
  switch (v.getId()) {
   case R.id.tv_save:
    if(type==GlobalParams.TYPE_EDIT){
     update();
    }else {
     save();
    }
    break;
   case R.id.tv_date:
    selectDateDialog();
    break;
   case R.id.tv_time:
    selectTimeDialog();
    break;
   case R.id.tv_cancel:
    finish();
    break;
  }
 }
 private void selectDateDialog(){
  Calendar c = Calendar.getInstance();
  int year=c.get(Calendar.YEAR);
  final int month=c.get(Calendar.MONTH)+1;
  int day=c.get(Calendar.DAY_OF_MONTH);
  new DatePickerDialog(AddContentActivity.this, new DatePickerDialog.OnDateSetListener() {
   @Override
   public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    date=getDate(year,monthOfYear,dayOfMonth);
    tv_date.setText(date);
   }
  },year,month,day).show();
 }

 private void selectTimeDialog() {
  Calendar c = Calendar.getInstance();
  int mHour = c.get(Calendar.HOUR_OF_DAY);
  int mMinute = c.get(Calendar.MINUTE);
  new TimePickerDialog(AddContentActivity.this,
    new TimePickerDialog.OnTimeSetListener() {

     @Override
     public void onTimeSet(TimePicker view,
           int hourOfDay, int minute) {
      time=formatTime(hourOfDay,minute);
      tv_time.setText(time);
     }
    }, mHour, mMinute, true).show();
 }

 private String formatTime(int hour,int minute){
  String time=hour+":";
  if(minute<10){
   time=time+"0"+minute;
  }else{
   time+=minute;
  }
  return time;
 }
 private void save() {
  String content = et_content.getText().toString();
  if ("".equals(content)) {
   Toast.makeText(AddContentActivity.this, "请输入内容", Toast.LENGTH_SHORT).show();
   return;
  }
  if ("".equals(time)) {
   Toast.makeText(AddContentActivity.this, "请选择时间", Toast.LENGTH_SHORT).show();
   return;
  }
  NotepadBean notepadBean = new NotepadBean();
  notepadBean.setContent(content);
  notepadBean.setDate(Integer.parseInt(date));
  notepadBean.setTime(time);
  DataHelper helper = new DataHelper(AddContentActivity.this);
  helper.insertData(notepadBean);
  setResult(GlobalParams.ADD_RESULT_OK);
  finish();
 }
 private void update(){
  DataHelper helper=new DataHelper(AddContentActivity.this);
  NotepadWithDataBean bean=(NotepadWithDataBean)(bundle.getSerializable(GlobalParams.BEAN_KEY));
  int itemPosition=bundle.getInt(GlobalParams.ITEM_POSITION_KEY);
  helper.update(bean.getNotepadBeenList().get(itemPosition).getId(),date,time,et_content.getText().toString());
  setResult(GlobalParams.ADD_RESULT_OK);
  finish();
 }
}

RemindActivity.java代码:

package siso.smartnotef.activity;

import android.media.MediaPlayer;
import android.media.RingtoneManager;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.io.IOException;

import siso.smartnotef.R;
import siso.smartnotef.global.GlobalParams;

public class RemindActivity extends AppCompatActivity {

 private TextView tv_content;
 private Button bt_confirm;
 private MediaPlayer mMediaPlayer;;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_remind);
  findViews();
  setListeners();
  Bundle bundle=getIntent().getExtras();
  String content=bundle.getString(GlobalParams.CONTENT_KEY);
  tv_content.setText(content);
  playSound();
 }

 private void findViews(){
  tv_content=(TextView)findViewById(R.id.tv_content);
  bt_confirm=(Button) findViewById(R.id.bt_confirm);
 }
 private void setListeners(){
  bt_confirm.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    if(null!=mMediaPlayer){
     mMediaPlayer.stop();
     finish();
    }
   }
  });
 }

 public void playSound() {
  new Thread(new Runnable() {
   @Override
   public void run() {
    mMediaPlayer = MediaPlayer.create(RemindActivity.this, getSystemDefultRingtoneUri());
    mMediaPlayer.setLooping(true);//设置循环
    try {
     mMediaPlayer.prepare();
    } catch (IllegalStateException e) {
     e.printStackTrace();
    } catch (IOException e) {
     e.printStackTrace();
    }
    mMediaPlayer.start();
   }
  }).start();

 }
 //获取系统默认铃声的Uri
 private Uri getSystemDefultRingtoneUri() {
  return RingtoneManager.getActualDefaultRingtoneUri(RemindActivity.this,
    RingtoneManager.TYPE_RINGTONE);
 }

}

activity_main.xml内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/activity_main"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 tools:context="siso.smartnotef.activity.MainActivity">

 <RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="50dp"
  android:background="@color/title_color"
  android:paddingLeft="10dp"
  android:paddingRight="10dp">
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textColor="@color/white"
   android:textSize="18sp"
   android:layout_centerInParent="true"
   android:text="智能记事本"/>
  <TextView
   android:id="@+id/tv_add"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textColor="@color/white"
   android:text="新增"
   android:layout_centerVertical="true"
   android:layout_alignParentRight="true"
   android:textSize="13sp"/>
 </RelativeLayout>
 <ListView
  android:id="@+id/lv_content"
  android:layout_width="match_parent"
  android:layout_height="wrap_content"></ListView>
</LinearLayout>

activity_add_content.xml内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:id="@+id/activity_add_content"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:orientation="vertical"
 tools:context="siso.smartnotef.activity.AddContentActivity">
 <RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="50dp"
  android:background="@color/title_color"
  android:paddingLeft="10dp"
  android:paddingRight="10dp">
  <TextView
   android:id="@+id/tv_cancel"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_centerVertical="true"
   android:text="取消"
   android:textColor="@color/white"/>
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textColor="@color/white"
   android:textSize="18sp"
   android:layout_centerInParent="true"
   android:text="智能记事本"/>
  <TextView
   android:id="@+id/tv_save"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textColor="@color/white"
   android:text="保存"
   android:layout_centerVertical="true"
   android:layout_alignParentRight="true"
   />
 </RelativeLayout>
 <LinearLayout
  android:layout_marginTop="10dp"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:layout_gravity="center_horizontal">
  <TextView
   android:id="@+id/tv_date"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:padding="5dp"
   android:text="今天"/>
  <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text=" -- "/>
  <TextView
   android:id="@+id/tv_time"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:padding="5dp"
   android:text="请选择时间"
   />
 </LinearLayout>
 <EditText
  android:id="@+id/et_content"
  android:layout_marginTop="10dp"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:inputType="textMultiLine"
  android:gravity="left|top"
  android:layout_margin="20dp"
  android:padding="10dp"
  android:hint="请输入内容"
  android:background="@drawable/edit_back"/>
</LinearLayout>

activity_remind.xml内容:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:background="@color/white"
 android:orientation="vertical"
 tools:context="siso.smartnotef.activity.RemindActivity">

 <TextView
  android:id="@+id/tv_content"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center_horizontal" />

 <Button
  android:id="@+id/bt_confirm"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center_horizontal"
  android:text="取消" />
</LinearLayout>

AndroidManifest.xml内容:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="siso.smartnotef">
 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
 <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

 <application
  android:allowBackup="true"
  android:icon="@mipmap/ic_launcher"
  android:label="@string/app_name"
  android:supportsRtl="true"
  android:theme="@style/Theme.AppCompat.Light.NoActionBar">

  <activity
   android:name=".activity.MainActivity"
   android:theme="@style/Theme.AppCompat.Light.NoActionBar">
   <intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
  </activity>

  <receiver android:name=".receiver.MainReceiver">
   <intent-filter>
    <action android:name="android.intent.action.BOOT_COMPLETED" />
   </intent-filter>
  </receiver>

  <activity android:name=".activity.AddContentActivity" />

  <service
   android:name=".service.MainService"
   android:enabled="true"
   android:exported="true" />

  <activity android:name=".activity.RemindActivity"
   ></activity>

 </application>

</manifest>

项目结构如图:

项目运行结果如图:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

时间: 2017-01-31

Android利用Intent实现记事本功能(NotePad)

本文实例为大家分享了Intent如何实现一个简单的记事本功能的演示过程,供大家参考,具体内容如下 1.运行截图 单击右上角[-]会弹出[添加]菜单项,长按某条记录会弹出快捷菜单[删除]项. 2.主要设计步骤 (1)添加引用 鼠标右击[引用]à[添加引用],在弹出的窗口中勾选"System.Data"和"System.Data.SQlite",如下图所示: 注意:不需要通过NuGet添加SQLite程序包,只需要按这种方式添加即可. (2)添加图片 到Android

Android中实现记事本动态添加行效果

本文主要给大家介绍了关于Android实现记事本动态添加行的相关内容,分享出来供大家参考学习,下面来一起看看详细的介绍: 先看效果图: 这是昨天在群里面有人在问这个问题,在这里顺便记录一下,这个效果我们可以自定义EditText,实现起来也不难 看详细步骤: 第一:初始化Paint,这里肯定要用到画笔的 this.paint = new Paint(); paint.setStyle(Paint.Style.STROKE); paint.setColor(getResources().getCo

Android中Activity滑动关闭的效果

最近感觉有一个Activity关闭的效果挺不错的,就是手势滑动就可以关闭当前Activity,于是就想写一篇博客和大家一起分享下!废话不多说,老规矩,还先上效果图,更直观! 项目地址:https://github.com/xinyitiandi/SlidingFinishDemo 上代码: 1.第一个Activity: package com.ekeguan.slidingfinishdemo; import android.content.Intent; import android.os.B

Android中自定义view实现侧滑效果

效果图: 看网上的都是两个view拼接,默认右侧的不显示,水平移动的时候把右侧的view显示出来.但是看最新版QQ上的效果不是这样的,但给人的感觉却很好,所以献丑来一发比较高仿的. 知识点: 1.ViewDragHelper 的用法: 2.滑动冲突的解决: 3.自定义viewgroup. ViewDragHelper 出来已经比较久了 相信大家都比较熟悉,不熟悉的话google一大把这里主要简单用一下它的几个方法 1.tryCaptureView(View child, int pointerI

Android中View跟随手指移动效果

最近做了一个项目中,其中遇到这样的需求要求图片移动到手指触碰的地方.具体实现代码如下所示: package com.example.plane; import Android.app.Activity; import android.os.Bundle; import android.util.DisplayMetrics; import android.view.Display; import android.view.KeyEvent; import android.view.Menu; i

Android中View跟随手指滑动效果的实例代码

本文讲述了Android中View跟随手指滑动效果的实例代码.分享给大家供大家参考,具体如下: 1.android View 主要6种滑动方法,分别是 layout() offsetLeftAndRight()和offsetTopAndBottom() LayoutParams scrollBy()和 scrollTo() Scroller 动画 2.实现效果图 3.自定义中使用layout()方法实习view的滑动 public class MoveView extends View { pr

详解Android中的沉浸式状态栏效果实例

无意间了解到沉浸式状态栏,感觉贼拉的高大上,于是就是试着去了解一下,就有了这篇文章.下面就来了解一下啥叫沉浸式状态栏.传统的手机状态栏是呈现出黑色条状的,有的和手机主界面有很明显的区别.这一样就在一定程度上牺牲了视觉宽度,界面面积变小. Google从android kitkat(Android 4.4)开始,给我们开发者提供了一套能透明的系统ui样式给状态栏和导航栏,这样的话就不用向以前那样每天面对着黑乎乎的上下两条黑栏了,还可以调成跟Activity一样的样式,形成一个完整的主题,和IOS7

Android中不支持动态申请权限的原因

作为Android开发者,为程序增加权限是在正常不过的事情了,做法必然是在mainifest中,写入类似这样<uses-permission android:name="android.permission.INTERNET" />的信息. 以静态申请的形式来完成. 于是这里我想抛出一个问题,Android平台支持动态申请权限么. 相信很多人回答都是不支持,当然这个答案是对的,但是为什么不支持呢,知其然更要知其所以然.了解其原因还是相当有必要的. 原因列举 Android没

android 中ProgressDialog实现全屏效果的示例

做项目的时候,直接用到了一个ProgressDialog,需要实现全屏的效果,如下图所示,功能跑起来的时候发现不是全屏,只是包裹了当前的内容,如下图所示,不过查找一些资料,把问题解决了. ProgressDialog 继承自AlertDialog,AlertDialog继承自Dialog,实现DialogInterface接口. ProgressDialog的创建方式有两种,一种是new Dialog ,一种是调用Dialog的静态方法Dialog.show(). // 方式一:new Dial

Android中DrawerLayout实现侧滑菜单效果

众所周知,android里面我们很熟悉的一个功能,侧滑菜单效果在以前我们大部分都是用的slidingmenu这个开源框架,自从谷歌官方新出的一个DrawerLayout控件之后,越来越多的应用开始使用谷歌的官方的控件写这个效果了. 话不多说,先来发图以表我滴诚意: 开始写代码 DrawerLayout 是v4包里面的,所以项目里面需要添加v4包,具体怎么添加就不多说了, NavigationView需要在build.gradle里面添加compile 'com.android.support:d

android中RecyclerView悬浮吸顶效果

MultiType-Adapter打造悬浮吸顶效果 注:当前版本只适合配合RecyclerView快速打造一款 展示UI 悬浮吸顶效果,如 通讯录效果,由于实现机制的原因,暂时不支持触摸事件. MultiType-Adapter介绍地址:MultiType-Adapter 是一款轻量级支持多数据类型的 RecyclerView 适配器; 使用简单,完全解耦; 悬浮吸顶效果 ```groovy // root build.gradle repositories { jcenter() maven