根据autocompletetextview上的输入数据计算的总建议数-Android

时间:2019-03-22 09:38:51

标签: java android autocompletetextview

如何获得总数的建议,该建议与autocompletetextview上的输入数据完全匹配

 placeView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    Places item = (Places) parent.getItemAtPosition(position);
                    if(!place_id.equals("")) {
                        place_name = item.getPlaceName();
                        place_id = item.getOnlineId();
                        place_panchayat_id = item.getPanchayat_name();
                    } else {
                        placeView.setText("");
                    }

                }
            });

1 个答案:

答案 0 :(得分:0)

尝试一下,

placeView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //getCount() Method give the count from the adapter;
                int count = parent.getCount();
                Places item = (Places) parent.getItemAtPosition(position);
                if(!place_id.equals("")) {
                    place_name = item.getPlaceName();
                    place_id = item.getOnlineId();
                    place_panchayat_id = item.getPanchayat_name();
                } else {
                    placeView.setText("");
                }

            }
        });