DrawerLayout+ListView+AutoCompleteTextView实现侧滑+提示+筛选+再次筛选数据功能

在发表前我想表达一下自己的感受吐舌头。。。。。


写这个项目一共花了我3天时间,其中前两天基本一天12小时都在写,虽然当时写的很累,不过写成后真的感觉心情很不错,呵呵呵大笑

先来张图看下效果:

这是打开时的界面


然后点击筛选,就会弹出一个侧滑页面,输入A,当然你也可以输入B或C,如图

就会筛选出你输入的字母开头的列


最后再点击再次筛选,就会对这个页面进行再次筛选,输入1或2或3,如图

就会对这个界面进行再次筛选了,具体功能还需自己复制,然后粘贴。

自己体验过后才能明白,我就不多说了。



下面附上代码:




首先创建一个项目名为DrawerLayout的安卓APP,当然也可以自定义命名。。。

然后在主MainActivity复制如下代码


package com.example.drawerlayout;


import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.text.Editable;
import android.text.TextWatcher;


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


import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;


public class MainActivity extends Activity{
private DrawerLayout mDrawerLayout;
private Button frwhs,bt3;
private AutoCompleteTextView autoTv;  
private ListView listView;
private List<Model> demos;
private List<Model> datas;
private List<Model> datas1;
private ArrayList<Integer> ary;
private String f;
private Myadapter adapter;
private ArrayAdapter<String> autoadapter;
private HashMap<Integer, String> hashMap;


boolean a=true;


String[] str={"A1","B1","C1","113","124","125"};




@SuppressLint("UseSparseArrays")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
frwhs = (Button) findViewById(R.id.spinner1);
bt3 = (Button) findViewById(R.id.bt3);
autoTv=(AutoCompleteTextView) findViewById(R.id.auto);
listView=(ListView) findViewById(R.id.listView1);


demos=new ArrayList<Model>();
datas=new ArrayList<Model>();
datas1=new ArrayList<Model>();
ary = new ArrayList<Integer>();
hashMap = new HashMap<Integer, String>();  


demos.add(new Model("A1","113","bt1","bt2"));
demos.add(new Model("A1","124",&#

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值