如何使用搜索视图来查看自定义列表视图

时间:2015-08-30 12:40:01

标签: android listview searchview

您好我已经搜索了几个小时试图获取搜索视图来搜索700多行的列表视图,这些行包含2x textviews,使用strings.xml文件通过使用数组和1x imageview填充整数数组填充imageview(s)。我真的需要一些帮助。到目前为止,我已经让它在打字时没有崩溃,但它只是在弹出窗口中显示正在搜索的文本。这是我的代码。

主要活动:

public class NationalDex extends Activity implements SearchView.OnQueryTextListener {
ListView l;
AdapterHand mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.nationaldexlist);
    l = (ListView) findViewById(R.id.listView1);
    l.setAdapter(new AdapterHand(this));
    getActionBar().setDisplayHomeAsUpEnabled(true);
    l.setTextFilterEnabled(true);


    l.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            switch (position) {
                case 0: {
                    Intent intent = new Intent(NationalDex.this, BulbaTab.class);
                    intent.putExtra("FROM_ACTIVITY", "National");
                    startActivity(intent);
                    finish();
                    break;
                }
                case 1: {
                    Intent intent = new Intent(NationalDex.this, IvyTab.class);
                    intent.putExtra("FROM_ACTIVITY", "National");
                    startActivity(intent);
                    finish();
                    break;
                }
                case 2: {
                    Intent intent = new Intent(NationalDex.this, VenuTab.class);
                    startActivity(intent);
                    finish();
                    break;
                }
                default:
                    break;

            }
        }
    });

}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case android.R.id.home:
            // API 5+ solution
            onBackPressed();
            return true;

        default:
            return super.onOptionsItemSelected(item);
    }
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);
    SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    searchView.setSubmitButtonEnabled(true);
    searchView.setOnQueryTextListener(this);
    return true;
}

@Override
public boolean onQueryTextSubmit(String s) {
    return false;
}

@Override
public boolean onQueryTextChange(String s) {
    if(TextUtils.isEmpty(s))
    {
        l.clearTextFilter();
    }
    else{
       l.setFilterText(s.toString());

    }
    return true;
}

查看持有人:

class viewHolder {
    ImageView myImage;
    TextView myTitle;
    TextView myDescription;

    viewHolder(View v) {
        myTitle = (TextView) v.findViewById(R.id.textView);
        myDescription = (TextView) v.findViewById(R.id.textView2);
        myImage = (ImageView) v.findViewById(R.id.imageView);
    }
}

单行:

class SingleRow {
    String title;
    String description;
    int balls;

    SingleRow(String title, String description, int balls) {
        this.title = title;
        this.description = description;
        this.balls = balls;


    }

}

基础适配器:

class AdapterHand extends BaseAdapter {
    private ArrayList<SingleRow> list = new ArrayList<SingleRow>();
    Context context;

    AdapterHand(Context c) {
        context = c;
        list = new ArrayList<>();
        Resources res = c.getResources();
        String[] title = res.getStringArray(R.array.nationaltitles);
        String[] description = res.getStringArray(R.array.nationalids);
        int[] balls = {
                R.drawable.national001, R.drawable.national002, R.drawable.national003,
                R.drawable.national004, R.drawable.national005, R.drawable.national006,
                R.drawable.national007, R.drawable.national008, R.drawable.national009,
                R.drawable.national010, R.drawable.national011, R.drawable.national012,
                R.drawable.national013, R.drawable.national014, R.drawable.national015,
                R.drawable.national016, R.drawable.national017, R.drawable.national018,
                R.drawable.national019, R.drawable.national020, R.drawable.national021,
                R.drawable.national022, R.drawable.national023, R.drawable.national024,
                R.drawable.national025, R.drawable.national026, R.drawable.national027,
                R.drawable.national028, R.drawable.national029, R.drawable.national030,
                R.drawable.national031, R.drawable.national032, R.drawable.national033,
                R.drawable.national034, R.drawable.national035, R.drawable.national036,
                R.drawable.national037, R.drawable.national038, R.drawable.national039,
                R.drawable.national040, R.drawable.national041, R.drawable.national042,
                R.drawable.national043, R.drawable.national044, R.drawable.national045,
                R.drawable.national046, R.drawable.national047, R.drawable.national048,
                R.drawable.national049, R.drawable.national050, R.drawable.national051,
                R.drawable.national052, R.drawable.national053, R.drawable.national054,
                R.drawable.national055, R.drawable.national056, R.drawable.national057,
                R.drawable.national058, R.drawable.national059, R.drawable.national060,
                R.drawable.national061, R.drawable.national062, R.drawable.national063,
                R.drawable.national064, R.drawable.national065, R.drawable.national066,
                R.drawable.national067, R.drawable.national068, R.drawable.national069,
                R.drawable.national070, R.drawable.national071, R.drawable.national072,
                R.drawable.national073, R.drawable.national074, R.drawable.national075,
                R.drawable.national076, R.drawable.national077, R.drawable.national078,
                R.drawable.national079, R.drawable.national080, R.drawable.national081,
                R.drawable.national082, R.drawable.national083, R.drawable.national084,
                R.drawable.national085, R.drawable.national086, R.drawable.national087,
                R.drawable.national088, R.drawable.national089, R.drawable.national090,
                R.drawable.national091, R.drawable.national092, R.drawable.national093,
                R.drawable.national094, R.drawable.national095, R.drawable.national096,
                R.drawable.national097, R.drawable.national098, R.drawable.national099,
                R.drawable.national100, R.drawable.national101, R.drawable.national102,
                R.drawable.national103, R.drawable.national104, R.drawable.national105,
                R.drawable.national106, R.drawable.national107, R.drawable.national108,
                R.drawable.national109, R.drawable.national110, R.drawable.national111,
                R.drawable.national112, R.drawable.national113, R.drawable.national114,
                R.drawable.national115, R.drawable.national116, R.drawable.national117,
                R.drawable.national118, R.drawable.national119, R.drawable.national120,
                R.drawable.national121, R.drawable.national122, R.drawable.national123,
                R.drawable.national124, R.drawable.national125, R.drawable.national126,
                R.drawable.national127, R.drawable.national128, R.drawable.national129,
                R.drawable.national130, R.drawable.national131, R.drawable.national132,
                R.drawable.national133, R.drawable.national134, R.drawable.national135,
                R.drawable.national136, R.drawable.national137, R.drawable.national138,
                R.drawable.national139, R.drawable.national140, R.drawable.national141,
                R.drawable.national142, R.drawable.national143, R.drawable.national144,
                R.drawable.national145, R.drawable.national146, R.drawable.national147,
                R.drawable.national148, R.drawable.national149, R.drawable.national150,
                R.drawable.national151, R.drawable.national152, R.drawable.national153,
                R.drawable.national154, R.drawable.national155, R.drawable.national156,
                R.drawable.national157, R.drawable.national158, R.drawable.national159,
                R.drawable.national160, R.drawable.national161, R.drawable.national162,
                R.drawable.national163, R.drawable.national164, R.drawable.national165,
                R.drawable.national166, R.drawable.national167, R.drawable.national168,
                R.drawable.national169, R.drawable.national170, R.drawable.national171,
                R.drawable.national172, R.drawable.national173, R.drawable.national174,
                R.drawable.national175, R.drawable.national176, R.drawable.national177,
                R.drawable.national178, R.drawable.national179, R.drawable.national180,
                R.drawable.national181, R.drawable.national182, R.drawable.national183,
                R.drawable.national184, R.drawable.national185, R.drawable.national186,
                R.drawable.national187, R.drawable.national188, R.drawable.national189,
                R.drawable.national190, R.drawable.national191, R.drawable.national192,
                R.drawable.national193, R.drawable.national194, R.drawable.national195,
                R.drawable.national196, R.drawable.national197, R.drawable.national198,
                R.drawable.national199, R.drawable.national200, R.drawable.national201,
                R.drawable.national202, R.drawable.national203, R.drawable.national204,
                R.drawable.national205, R.drawable.national206, R.drawable.national207,
                R.drawable.national208, R.drawable.national209, R.drawable.national210,
                R.drawable.national211, R.drawable.national212, R.drawable.national213,
                R.drawable.national214, R.drawable.national215, R.drawable.national216,
                R.drawable.national217, R.drawable.national218, R.drawable.national219,
                R.drawable.national220, R.drawable.national221, R.drawable.national222,
                R.drawable.national223, R.drawable.national224, R.drawable.national225,
                R.drawable.national226, R.drawable.national227, R.drawable.national228,
                R.drawable.national229, R.drawable.national230, R.drawable.national231,
                R.drawable.national232, R.drawable.national233, R.drawable.national234,
                R.drawable.national235, R.drawable.national236, R.drawable.national237,
                R.drawable.national238, R.drawable.national239, R.drawable.national240,
                R.drawable.national241, R.drawable.national242, R.drawable.national243,
                R.drawable.national244, R.drawable.national245, R.drawable.national246,
                R.drawable.national247, R.drawable.national248, R.drawable.national249,
                R.drawable.national250, R.drawable.national251, R.drawable.national252,
                R.drawable.national253, R.drawable.national254, R.drawable.national255,
                R.drawable.national256,
                R.drawable.national257, R.drawable.national258, R.drawable.national259,
                R.drawable.national260, R.drawable.national261, R.drawable.national262,
                R.drawable.national263, R.drawable.national264, R.drawable.national265,
                R.drawable.national266, R.drawable.national267, R.drawable.national268,
                R.drawable.national269, R.drawable.national270, R.drawable.national271,
                R.drawable.national272, R.drawable.national273, R.drawable.national274,
                R.drawable.national275, R.drawable.national276, R.drawable.national277,
                R.drawable.national278, R.drawable.national279, R.drawable.national280,
                R.drawable.national281, R.drawable.national282, R.drawable.national283,
                R.drawable.national284, R.drawable.national285, R.drawable.national286,
                R.drawable.national287, R.drawable.national288, R.drawable.national289,
                R.drawable.national290, R.drawable.national291, R.drawable.national292,
                R.drawable.national293, R.drawable.national294, R.drawable.national295,
                R.drawable.national296, R.drawable.national297, R.drawable.national298,
                R.drawable.national299, R.drawable.national300, R.drawable.national301,
                R.drawable.national302, R.drawable.national303, R.drawable.national304,
                R.drawable.national305, R.drawable.national306, R.drawable.national307,
                R.drawable.national308, R.drawable.national309, R.drawable.national310,
                R.drawable.national311, R.drawable.national312, R.drawable.national313,
                R.drawable.national314, R.drawable.national315, R.drawable.national316,
                R.drawable.national317, R.drawable.national318, R.drawable.national319,
                R.drawable.national320, R.drawable.national321, R.drawable.national322,
                R.drawable.national323, R.drawable.national324, R.drawable.national325,
                R.drawable.national326, R.drawable.national327, R.drawable.national328,
                R.drawable.national329, R.drawable.national330, R.drawable.national331,
                R.drawable.national332, R.drawable.national333, R.drawable.national334,
                R.drawable.national335, R.drawable.national336, R.drawable.national337,
                R.drawable.national338, R.drawable.national339, R.drawable.national340,
                R.drawable.national341, R.drawable.national342, R.drawable.national343,
                R.drawable.national344, R.drawable.national345, R.drawable.national346,
                R.drawable.national347, R.drawable.national348, R.drawable.national349,
                R.drawable.national350, R.drawable.national351, R.drawable.national352,
                R.drawable.national353, R.drawable.national354,R.drawable.national355,
                R.drawable.national356, R.drawable.national357,
                R.drawable.national358, R.drawable.national359, R.drawable.national360,
                R.drawable.national361, R.drawable.national362, R.drawable.national363,
                R.drawable.national364, R.drawable.national365, R.drawable.national366,
                R.drawable.national367, R.drawable.national368, R.drawable.national369,
                R.drawable.national370, R.drawable.national371, R.drawable.national372,
                R.drawable.national373, R.drawable.national374, R.drawable.national375,
                R.drawable.national376, R.drawable.national377, R.drawable.national378,
                R.drawable.national379, R.drawable.national380, R.drawable.national381,
                R.drawable.national382, R.drawable.national383, R.drawable.national384,
                R.drawable.national385, R.drawable.national386, R.drawable.national387,
                R.drawable.national388, R.drawable.national389, R.drawable.national390,
                R.drawable.national391, R.drawable.national392, R.drawable.national393,
                R.drawable.national394, R.drawable.national395, R.drawable.national396,
                R.drawable.national397, R.drawable.national398, R.drawable.national399,
                R.drawable.national400, R.drawable.national401, R.drawable.national402,
                R.drawable.national403, R.drawable.national404, R.drawable.national405,
                R.drawable.national406, R.drawable.national407, R.drawable.national408,
                R.drawable.national409, R.drawable.national410, R.drawable.national411,
                R.drawable.national412, R.drawable.national413, R.drawable.national414,
                R.drawable.national415, R.drawable.national416, R.drawable.national417,
                R.drawable.national418, R.drawable.national419, R.drawable.national420,
                R.drawable.national421, R.drawable.national422, R.drawable.national423,
                R.drawable.national424, R.drawable.national425, R.drawable.national426,
                R.drawable.national427, R.drawable.national428, R.drawable.national429,
                R.drawable.national430, R.drawable.national431, R.drawable.national432,
                R.drawable.national433, R.drawable.national434, R.drawable.national435,
                R.drawable.national436, R.drawable.national437, R.drawable.national438,
                R.drawable.national439, R.drawable.national440, R.drawable.national441,
                R.drawable.national442, R.drawable.national443, R.drawable.national444,
                R.drawable.national445, R.drawable.national446, R.drawable.national447,
                R.drawable.national448, R.drawable.national449, R.drawable.national450,
                R.drawable.national451, R.drawable.national452, R.drawable.national453,
                R.drawable.national454, R.drawable.national455, R.drawable.national456,
                R.drawable.national457, R.drawable.national458, R.drawable.national459,
                R.drawable.national460, R.drawable.national461, R.drawable.national462,
                R.drawable.national463, R.drawable.national464, R.drawable.national465,
                R.drawable.national466, R.drawable.national467, R.drawable.national468,
                R.drawable.national469, R.drawable.national470, R.drawable.national471,
                R.drawable.national472, R.drawable.national473, R.drawable.national474,
                R.drawable.national475, R.drawable.national476, R.drawable.national477,
                R.drawable.national478, R.drawable.national479, R.drawable.national480,
                R.drawable.national481, R.drawable.national482, R.drawable.national483,
                R.drawable.national484, R.drawable.national485, R.drawable.national486,
                R.drawable.national487, R.drawable.national488, R.drawable.national489,
                R.drawable.national490, R.drawable.national491, R.drawable.national492,
                R.drawable.national493, R.drawable.national494, R.drawable.national495,
                R.drawable.national496, R.drawable.national497, R.drawable.national498,
                R.drawable.national499, R.drawable.national500, R.drawable.national501,
                R.drawable.national502, R.drawable.national503, R.drawable.national504,
                R.drawable.national505, R.drawable.national506, R.drawable.national507,
                R.drawable.national508, R.drawable.national509, R.drawable.national510,
                R.drawable.national511, R.drawable.national512, R.drawable.national513,
                R.drawable.national514, R.drawable.national515, R.drawable.national516,
                R.drawable.national517, R.drawable.national518, R.drawable.national519,
                R.drawable.national520, R.drawable.national521, R.drawable.national522,
                R.drawable.national523, R.drawable.national524, R.drawable.national525,
                R.drawable.national526, R.drawable.national527, R.drawable.national528,
                R.drawable.national529, R.drawable.national530, R.drawable.national531,
                R.drawable.national532, R.drawable.national533, R.drawable.national534,
                R.drawable.national535, R.drawable.national536, R.drawable.national537,
                R.drawable.national538, R.drawable.national539, R.drawable.national540,
                R.drawable.national541, R.drawable.national542, R.drawable.national543,
                R.drawable.national544, R.drawable.national545, R.drawable.national546,
                R.drawable.national547, R.drawable.national548, R.drawable.national549,
                R.drawable.national550, R.drawable.national551, R.drawable.national552,
                R.drawable.national553, R.drawable.national554, R.drawable.national555,
                R.drawable.national556, R.drawable.national557, R.drawable.national558,
                R.drawable.national559, R.drawable.national560, R.drawable.national561,
                R.drawable.national562, R.drawable.national563, R.drawable.national564,
                R.drawable.national565, R.drawable.national566, R.drawable.national567,
                R.drawable.national568, R.drawable.national569, R.drawable.national570,
                R.drawable.national571, R.drawable.national572, R.drawable.national573,
                R.drawable.national574, R.drawable.national575, R.drawable.national576,
                R.drawable.national577, R.drawable.national578, R.drawable.national579,
                R.drawable.national580, R.drawable.national581, R.drawable.national582,
                R.drawable.national583, R.drawable.national584, R.drawable.national585,
                R.drawable.national586, R.drawable.national587, R.drawable.national588,
                R.drawable.national589, R.drawable.national590, R.drawable.national591,
                R.drawable.national592, R.drawable.national593, R.drawable.national594,
                R.drawable.national595, R.drawable.national596, R.drawable.national597,
                R.drawable.national598, R.drawable.national599, R.drawable.national600,
                R.drawable.national601, R.drawable.national602, R.drawable.national603,
                R.drawable.national604, R.drawable.national605, R.drawable.national606,
                R.drawable.national607, R.drawable.national608, R.drawable.national609,
                R.drawable.national610, R.drawable.national611, R.drawable.national612,
                R.drawable.national613, R.drawable.national614, R.drawable.national615,
                R.drawable.national616, R.drawable.national617, R.drawable.national618,
                R.drawable.national619, R.drawable.national620, R.drawable.national621,
                R.drawable.national622, R.drawable.national623,  R.drawable.national624,
                R.drawable.national625,
                R.drawable.national626, R.drawable.national627, R.drawable.national628,
                R.drawable.national629, R.drawable.national630, R.drawable.national631,
                R.drawable.national632, R.drawable.national633, R.drawable.national634,
                R.drawable.national635, R.drawable.national636, R.drawable.national637,
                R.drawable.national638, R.drawable.national639, R.drawable.national640,
                R.drawable.national641, R.drawable.national642, R.drawable.national643,
                R.drawable.national644, R.drawable.national645, R.drawable.national646,
                R.drawable.national647, R.drawable.national648, R.drawable.national649,
                R.drawable.national650, R.drawable.national651, R.drawable.national652,
                R.drawable.national653, R.drawable.national654, R.drawable.national655,
                R.drawable.national656, R.drawable.national657, R.drawable.national658,
                R.drawable.national659, R.drawable.national660, R.drawable.national661,
                R.drawable.national662, R.drawable.national663, R.drawable.national664,
                R.drawable.national665, R.drawable.national666, R.drawable.national667,
                R.drawable.national668, R.drawable.national669, R.drawable.national670,
                R.drawable.national671, R.drawable.national672, R.drawable.national673,
                R.drawable.national674, R.drawable.national675, R.drawable.national676,
                R.drawable.national677, R.drawable.national678, R.drawable.national679,
                R.drawable.national680, R.drawable.national681, R.drawable.national682,
                R.drawable.national683, R.drawable.national684, R.drawable.national685,
                R.drawable.national686, R.drawable.national687, R.drawable.national688,
                R.drawable.national689, R.drawable.national690, R.drawable.national691,
                R.drawable.national692, R.drawable.national693, R.drawable.national694,
                R.drawable.national695, R.drawable.national696, R.drawable.national697,
                R.drawable.national698, R.drawable.national699, R.drawable.national700,
                R.drawable.national701, R.drawable.national702, R.drawable.national703,
                R.drawable.national704, R.drawable.national705, R.drawable.national706,
                R.drawable.national707, R.drawable.national708, R.drawable.national709,
                R.drawable.national710, R.drawable.national711, R.drawable.national712,
                R.drawable.national713, R.drawable.national714, R.drawable.national715,
                R.drawable.national716, R.drawable.national717, R.drawable.national718,
                R.drawable.national719, R.drawable.national720, R.drawable.national721


        };
        for (int i = 0; i < 721; i++) {
            list.add(new SingleRow(title[i], description[i], balls[i]));
        }


    }

    @Override
    public int getCount() {
        return list.size();

    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {


        View row = convertView;
        viewHolder holder = null;
        if (row == null) {
            LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = inflater.inflate(R.layout.single_row, null, false);
            holder = new viewHolder(row);
            row.setTag(holder);
            Log.d("MetaDex", "Creating");
        } else {
            holder = (viewHolder) row.getTag();
            Log.d("MetaDex", "Recycling");
        }

        SingleRow temp = list.get(i);


        holder.myTitle.setText(temp.title);
        holder.myDescription.setText(temp.description);
        holder.myImage.setImageResource(temp.balls);
        return row;
    }




}
}

1 个答案:

答案 0 :(得分:0)

我认为您应该使用适配器搜索。与
myAdapter.getFilter().filter(query);一样,在这种情况下,您需要在适配器中实现Filter。 Example

private class AdapterHand extends ArrayAdapter < SingleRow > {
    {
        private ArrayList < SingleRow > filteredArrayList;
        private ArrayList < SingleRow > originalList = new ArrayList < SingleRow > ();
        private HashMap < String, ArrayList < ContentValues >> timesHashMap;
        private Filter filter = new MyFilter();

        public SearchItemsAdapterNew(Context context) {
            super(context, 0, new ArrayList < SingleRow > ());
            this.filteredArrayList = originalList;
            Resources res = context.getResources();
            String[] title = res.getStringArray(R.array.nationaltitles);
            String[] description = res.getStringArray(R.array.nationalids);
            int[] balls = {
                R.drawable.national001, R.drawable.national002, R.drawable.national003,
                R.drawable.national004, R.drawable.national005, R.drawable.national006,
                R.drawable.national007, R.drawable.national008, R.drawable.national009,
                R.drawable.national010, R.drawable.national011, R.drawable.national012,
                R.drawable.national013, R.drawable.national014, R.drawable.national015,
                R.drawable.national016, R.drawable.national017, R.drawable.national018,
                R.drawable.national019, R.drawable.national020, R.drawable.national021,
                R.drawable.national022, R.drawable.national023, R.drawable.national024,
                R.drawable.national025, R.drawable.national026, R.drawable.national027,
                R.drawable.national028, R.drawable.national029, R.drawable.national030,
                R.drawable.national031, R.drawable.national032, R.drawable.national033,
                R.drawable.national034, R.drawable.national035, R.drawable.national036,
                R.drawable.national037, R.drawable.national038, R.drawable.national039,
                R.drawable.national040, R.drawable.national041, R.drawable.national042,
                R.drawable.national043, R.drawable.national044, R.drawable.national045,
                R.drawable.national046, R.drawable.national047, R.drawable.national048,
                R.drawable.national049, R.drawable.national050, R.drawable.national051,
                R.drawable.national052, R.drawable.national053, R.drawable.national054,
                R.drawable.national055, R.drawable.national056, R.drawable.national057,
                R.drawable.national058, R.drawable.national059, R.drawable.national060,
                R.drawable.national061, R.drawable.national062, R.drawable.national063,
                R.drawable.national064, R.drawable.national065, R.drawable.national066,
                R.drawable.national067, R.drawable.national068, R.drawable.national069,
                R.drawable.national070, R.drawable.national071, R.drawable.national072,
                R.drawable.national073, R.drawable.national074, R.drawable.national075,
                R.drawable.national076, R.drawable.national077, R.drawable.national078,
                R.drawable.national079, R.drawable.national080, R.drawable.national081,
                R.drawable.national082, R.drawable.national083, R.drawable.national084,
                R.drawable.national085, R.drawable.national086, R.drawable.national087,
                R.drawable.national088, R.drawable.national089, R.drawable.national090,
                R.drawable.national091, R.drawable.national092, R.drawable.national093,
                R.drawable.national094, R.drawable.national095, R.drawable.national096,
                R.drawable.national097, R.drawable.national098, R.drawable.national099,
                R.drawable.national100, R.drawable.national101, R.drawable.national102,
                R.drawable.national103, R.drawable.national104, R.drawable.national105,
                R.drawable.national106, R.drawable.national107, R.drawable.national108,
                R.drawable.national109, R.drawable.national110, R.drawable.national111,
                R.drawable.national112, R.drawable.national113, R.drawable.national114,
                R.drawable.national115, R.drawable.national116, R.drawable.national117,
                R.drawable.national118, R.drawable.national119, R.drawable.national120,
                R.drawable.national121, R.drawable.national122, R.drawable.national123,
                R.drawable.national124, R.drawable.national125, R.drawable.national126,
                R.drawable.national127, R.drawable.national128, R.drawable.national129,
                R.drawable.national130, R.drawable.national131, R.drawable.national132,
                R.drawable.national133, R.drawable.national134, R.drawable.national135,
                R.drawable.national136, R.drawable.national137, R.drawable.national138,
                R.drawable.national139, R.drawable.national140, R.drawable.national141,
                R.drawable.national142, R.drawable.national143, R.drawable.national144,
                R.drawable.national145, R.drawable.national146, R.drawable.national147,
                R.drawable.national148, R.drawable.national149, R.drawable.national150,
                R.drawable.national151, R.drawable.national152, R.drawable.national153,
                R.drawable.national154, R.drawable.national155, R.drawable.national156,
                R.drawable.national157, R.drawable.national158, R.drawable.national159,
                R.drawable.national160, R.drawable.national161, R.drawable.national162,
                R.drawable.national163, R.drawable.national164, R.drawable.national165,
                R.drawable.national166, R.drawable.national167, R.drawable.national168,
                R.drawable.national169, R.drawable.national170, R.drawable.national171,
                R.drawable.national172, R.drawable.national173, R.drawable.national174,
                R.drawable.national175, R.drawable.national176, R.drawable.national177,
                R.drawable.national178, R.drawable.national179, R.drawable.national180,
                R.drawable.national181, R.drawable.national182, R.drawable.national183,
                R.drawable.national184, R.drawable.national185, R.drawable.national186,
                R.drawable.national187, R.drawable.national188, R.drawable.national189,
                R.drawable.national190, R.drawable.national191, R.drawable.national192,
                R.drawable.national193, R.drawable.national194, R.drawable.national195,
                R.drawable.national196, R.drawable.national197, R.drawable.national198,
                R.drawable.national199, R.drawable.national200, R.drawable.national201,
                R.drawable.national202, R.drawable.national203, R.drawable.national204,
                R.drawable.national205, R.drawable.national206, R.drawable.national207,
                R.drawable.national208, R.drawable.national209, R.drawable.national210,
                R.drawable.national211, R.drawable.national212, R.drawable.national213,
                R.drawable.national214, R.drawable.national215, R.drawable.national216,
                R.drawable.national217, R.drawable.national218, R.drawable.national219,
                R.drawable.national220, R.drawable.national221, R.drawable.national222,
                R.drawable.national223, R.drawable.national224, R.drawable.national225,
                R.drawable.national226, R.drawable.national227, R.drawable.national228,
                R.drawable.national229, R.drawable.national230, R.drawable.national231,
                R.drawable.national232, R.drawable.national233, R.drawable.national234,
                R.drawable.national235, R.drawable.national236, R.drawable.national237,
                R.drawable.national238, R.drawable.national239, R.drawable.national240,
                R.drawable.national241, R.drawable.national242, R.drawable.national243,
                R.drawable.national244, R.drawable.national245, R.drawable.national246,
                R.drawable.national247, R.drawable.national248, R.drawable.national249,
                R.drawable.national250, R.drawable.national251, R.drawable.national252,
                R.drawable.national253, R.drawable.national254, R.drawable.national255,
                R.drawable.national256,
                R.drawable.national257, R.drawable.national258, R.drawable.national259,
                R.drawable.national260, R.drawable.national261, R.drawable.national262,
                R.drawable.national263, R.drawable.national264, R.drawable.national265,
                R.drawable.national266, R.drawable.national267, R.drawable.national268,
                R.drawable.national269, R.drawable.national270, R.drawable.national271,
                R.drawable.national272, R.drawable.national273, R.drawable.national274,
                R.drawable.national275, R.drawable.national276, R.drawable.national277,
                R.drawable.national278, R.drawable.national279, R.drawable.national280,
                R.drawable.national281, R.drawable.national282, R.drawable.national283,
                R.drawable.national284, R.drawable.national285, R.drawable.national286,
                R.drawable.national287, R.drawable.national288, R.drawable.national289,
                R.drawable.national290, R.drawable.national291, R.drawable.national292,
                R.drawable.national293, R.drawable.national294, R.drawable.national295,
                R.drawable.national296, R.drawable.national297, R.drawable.national298,
                R.drawable.national299, R.drawable.national300, R.drawable.national301,
                R.drawable.national302, R.drawable.national303, R.drawable.national304,
                R.drawable.national305, R.drawable.national306, R.drawable.national307,
                R.drawable.national308, R.drawable.national309, R.drawable.national310,
                R.drawable.national311, R.drawable.national312, R.drawable.national313,
                R.drawable.national314, R.drawable.national315, R.drawable.national316,
                R.drawable.national317, R.drawable.national318, R.drawable.national319,
                R.drawable.national320, R.drawable.national321, R.drawable.national322,
                R.drawable.national323, R.drawable.national324, R.drawable.national325,
                R.drawable.national326, R.drawable.national327, R.drawable.national328,
                R.drawable.national329, R.drawable.national330, R.drawable.national331,
                R.drawable.national332, R.drawable.national333, R.drawable.national334,
                R.drawable.national335, R.drawable.national336, R.drawable.national337,
                R.drawable.national338, R.drawable.national339, R.drawable.national340,
                R.drawable.national341, R.drawable.national342, R.drawable.national343,
                R.drawable.national344, R.drawable.national345, R.drawable.national346,
                R.drawable.national347, R.drawable.national348, R.drawable.national349,
                R.drawable.national350, R.drawable.national351, R.drawable.national352,
                R.drawable.national353, R.drawable.national354, R.drawable.national355,
                R.drawable.national356, R.drawable.national357,
                R.drawable.national358, R.drawable.national359, R.drawable.national360,
                R.drawable.national361, R.drawable.national362, R.drawable.national363,
                R.drawable.national364, R.drawable.national365, R.drawable.national366,
                R.drawable.national367, R.drawable.national368, R.drawable.national369,
                R.drawable.national370, R.drawable.national371, R.drawable.national372,
                R.drawable.national373, R.drawable.national374, R.drawable.national375,
                R.drawable.national376, R.drawable.national377, R.drawable.national378,
                R.drawable.national379, R.drawable.national380, R.drawable.national381,
                R.drawable.national382, R.drawable.national383, R.drawable.national384,
                R.drawable.national385, R.drawable.national386, R.drawable.national387,
                R.drawable.national388, R.drawable.national389, R.drawable.national390,
                R.drawable.national391, R.drawable.national392, R.drawable.national393,
                R.drawable.national394, R.drawable.national395, R.drawable.national396,
                R.drawable.national397, R.drawable.national398, R.drawable.national399,
                R.drawable.national400, R.drawable.national401, R.drawable.national402,
                R.drawable.national403, R.drawable.national404, R.drawable.national405,
                R.drawable.national406, R.drawable.national407, R.drawable.national408,
                R.drawable.national409, R.drawable.national410, R.drawable.national411,
                R.drawable.national412, R.drawable.national413, R.drawable.national414,
                R.drawable.national415, R.drawable.national416, R.drawable.national417,
                R.drawable.national418, R.drawable.national419, R.drawable.national420,
                R.drawable.national421, R.drawable.national422, R.drawable.national423,
                R.drawable.national424, R.drawable.national425, R.drawable.national426,
                R.drawable.national427, R.drawable.national428, R.drawable.national429,
                R.drawable.national430, R.drawable.national431, R.drawable.national432,
                R.drawable.national433, R.drawable.national434, R.drawable.national435,
                R.drawable.national436, R.drawable.national437, R.drawable.national438,
                R.drawable.national439, R.drawable.national440, R.drawable.national441,
                R.drawable.national442, R.drawable.national443, R.drawable.national444,
                R.drawable.national445, R.drawable.national446, R.drawable.national447,
                R.drawable.national448, R.drawable.national449, R.drawable.national450,
                R.drawable.national451, R.drawable.national452, R.drawable.national453,
                R.drawable.national454, R.drawable.national455, R.drawable.national456,
                R.drawable.national457, R.drawable.national458, R.drawable.national459,
                R.drawable.national460, R.drawable.national461, R.drawable.national462,
                R.drawable.national463, R.drawable.national464, R.drawable.national465,
                R.drawable.national466, R.drawable.national467, R.drawable.national468,
                R.drawable.national469, R.drawable.national470, R.drawable.national471,
                R.drawable.national472, R.drawable.national473, R.drawable.national474,
                R.drawable.national475, R.drawable.national476, R.drawable.national477,
                R.drawable.national478, R.drawable.national479, R.drawable.national480,
                R.drawable.national481, R.drawable.national482, R.drawable.national483,
                R.drawable.national484, R.drawable.national485, R.drawable.national486,
                R.drawable.national487, R.drawable.national488, R.drawable.national489,
                R.drawable.national490, R.drawable.national491, R.drawable.national492,
                R.drawable.national493, R.drawable.national494, R.drawable.national495,
                R.drawable.national496, R.drawable.national497, R.drawable.national498,
                R.drawable.national499, R.drawable.national500, R.drawable.national501,
                R.drawable.national502, R.drawable.national503, R.drawable.national504,
                R.drawable.national505, R.drawable.national506, R.drawable.national507,
                R.drawable.national508, R.drawable.national509, R.drawable.national510,
                R.drawable.national511, R.drawable.national512, R.drawable.national513,
                R.drawable.national514, R.drawable.national515, R.drawable.national516,
                R.drawable.national517, R.drawable.national518, R.drawable.national519,
                R.drawable.national520, R.drawable.national521, R.drawable.national522,
                R.drawable.national523, R.drawable.national524, R.drawable.national525,
                R.drawable.national526, R.drawable.national527, R.drawable.national528,
                R.drawable.national529, R.drawable.national530, R.drawable.national531,
                R.drawable.national532, R.drawable.national533, R.drawable.national534,
                R.drawable.national535, R.drawable.national536, R.drawable.national537,
                R.drawable.national538, R.drawable.national539, R.drawable.national540,
                R.drawable.national541, R.drawable.national542, R.drawable.national543,
                R.drawable.national544, R.drawable.national545, R.drawable.national546,
                R.drawable.national547, R.drawable.national548, R.drawable.national549,
                R.drawable.national550, R.drawable.national551, R.drawable.national552,
                R.drawable.national553, R.drawable.national554, R.drawable.national555,
                R.drawable.national556, R.drawable.national557, R.drawable.national558,
                R.drawable.national559, R.drawable.national560, R.drawable.national561,
                R.drawable.national562, R.drawable.national563, R.drawable.national564,
                R.drawable.national565, R.drawable.national566, R.drawable.national567,
                R.drawable.national568, R.drawable.national569, R.drawable.national570,
                R.drawable.national571, R.drawable.national572, R.drawable.national573,
                R.drawable.national574, R.drawable.national575, R.drawable.national576,
                R.drawable.national577, R.drawable.national578, R.drawable.national579,
                R.drawable.national580, R.drawable.national581, R.drawable.national582,
                R.drawable.national583, R.drawable.national584, R.drawable.national585,
                R.drawable.national586, R.drawable.national587, R.drawable.national588,
                R.drawable.national589, R.drawable.national590, R.drawable.national591,
                R.drawable.national592, R.drawable.national593, R.drawable.national594,
                R.drawable.national595, R.drawable.national596, R.drawable.national597,
                R.drawable.national598, R.drawable.national599, R.drawable.national600,
                R.drawable.national601, R.drawable.national602, R.drawable.national603,
                R.drawable.national604, R.drawable.national605, R.drawable.national606,
                R.drawable.national607, R.drawable.national608, R.drawable.national609,
                R.drawable.national610, R.drawable.national611, R.drawable.national612,
                R.drawable.national613, R.drawable.national614, R.drawable.national615,
                R.drawable.national616, R.drawable.national617, R.drawable.national618,
                R.drawable.national619, R.drawable.national620, R.drawable.national621,
                R.drawable.national622, R.drawable.national623, R.drawable.national624,
                R.drawable.national625,
                R.drawable.national626, R.drawable.national627, R.drawable.national628,
                R.drawable.national629, R.drawable.national630, R.drawable.national631,
                R.drawable.national632, R.drawable.national633, R.drawable.national634,
                R.drawable.national635, R.drawable.national636, R.drawable.national637,
                R.drawable.national638, R.drawable.national639, R.drawable.national640,
                R.drawable.national641, R.drawable.national642, R.drawable.national643,
                R.drawable.national644, R.drawable.national645, R.drawable.national646,
                R.drawable.national647, R.drawable.national648, R.drawable.national649,
                R.drawable.national650, R.drawable.national651, R.drawable.national652,
                R.drawable.national653, R.drawable.national654, R.drawable.national655,
                R.drawable.national656, R.drawable.national657, R.drawable.national658,
                R.drawable.national659, R.drawable.national660, R.drawable.national661,
                R.drawable.national662, R.drawable.national663, R.drawable.national664,
                R.drawable.national665, R.drawable.national666, R.drawable.national667,
                R.drawable.national668, R.drawable.national669, R.drawable.national670,
                R.drawable.national671, R.drawable.national672, R.drawable.national673,
                R.drawable.national674, R.drawable.national675, R.drawable.national676,
                R.drawable.national677, R.drawable.national678, R.drawable.national679,
                R.drawable.national680, R.drawable.national681, R.drawable.national682,
                R.drawable.national683, R.drawable.national684, R.drawable.national685,
                R.drawable.national686, R.drawable.national687, R.drawable.national688,
                R.drawable.national689, R.drawable.national690, R.drawable.national691,
                R.drawable.national692, R.drawable.national693, R.drawable.national694,
                R.drawable.national695, R.drawable.national696, R.drawable.national697,
                R.drawable.national698, R.drawable.national699, R.drawable.national700,
                R.drawable.national701, R.drawable.national702, R.drawable.national703,
                R.drawable.national704, R.drawable.national705, R.drawable.national706,
                R.drawable.national707, R.drawable.national708, R.drawable.national709,
                R.drawable.national710, R.drawable.national711, R.drawable.national712,
                R.drawable.national713, R.drawable.national714, R.drawable.national715,
                R.drawable.national716, R.drawable.national717, R.drawable.national718,
                R.drawable.national719, R.drawable.national720, R.drawable.national721
            };
            for (int i = 0; i < balls.length; i++) {
                originalList.add(new SingleRow(title[i], description[i], balls[i]));
            }
        }

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View row = convertView;
            viewHolder holder;
            if (row == null) {
                row = LayoutInflater.from(getContext()).inflate(R.layout.single_row, null, false);
                holder = new viewHolder(row);
                row.setTag(holder);
            } else {
                holder = (viewHolder) row.getTag();
            }
            SingleRow temp = getItem(position);

            holder.myTitle.setText(temp.title);
            holder.myDescription.setText(temp.description);
            holder.myImage.setImageResource(temp.balls);
            return row;
        }

        @Override
        public SingleRow getItem(int position) {
            return filteredArrayList.get(position);

        @Override
        public int getCount() {
            return filteredArrayList.size();
        }

        @Override
        public Filter getFilter() {
            return filter;
        }

        private class MyFilter extends Filter {
            @Override
            protected FilterResults performFiltering(CharSequence s) {
                String filterStr = s.toString().toLowerCase();
                FilterResults results = new FilterResults();
                if (filterStr.trim().length() < 2) {
                    results.values = originalList;
                    results.count = originalList.size();
                } else {
                    ArrayList < SingleRow > filteredItemsList = new ArrayList < SingleRow > ();
                    for (int i = 0; i < originalList.size(); i++) {
                        SingleRow singleRow = originalList.get(i); //thats your "combined" single row
                        if (singleRow.title.toLowerCase().contains(filterStr)) {
                            filteredItemsList.add(projectItem);
                        }
                    }
                    results.values = filteredItemsList;
                    results.count = filteredItemsList.size();
                }
                return results;
            }

            @Override
            protected void publishResults(CharSequence constraint, FilterResults results) {
                filteredArrayList = (ArrayList < SingleRow > ) results.values;
                notifyDataSetChanged();
            }
        }
    }