Incorrect position of elements after using customAdapter

This is the tutorial I used: http://www.tutorialsbuzz.com/2014/08/filter-custom-listviewbaseadapter.html

and I applied to it onItemClickListener

    OnItemClickListener myListViewClicked = new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            String member_name = countrylist.get(position).getName();
            // get Internet status
            isInternetPresent = cd.isConnectingToInternet();

            if (isInternetPresent) {
                if (member_name.equals("aa")) {
                    Intent i = new Intent(Listview.this, Start.class);
                    startActivity(i);
                    displayInterstitial();
            } else {
                prName.show();
            }
        }
    };
    lv.setOnItemClickListener(myListViewClicked);


}

so suppose my initial list

Aa
BB
Ca
DD

and I type 'a' in the filter, then the list becomes

Aa
Ca

But when I press Ca, I redirect to BB, using additional actions that depend on .equal for each list item.

My code for my list and user adapter is the same as in tutrial, but onclickitem listener, I executed it, so I think that they are missing something. I tried to find and find a couple of identical requests, but no one answered, each of them answered a question different from mine, and I could not apply it to my cusotm adapter.

+4
2

, .

 String member_name = countrylist.get(position).getName();

, , , Collection , Activity.

String member_name = ((Country)parent.getItemAtPosition(position)).getName();

.

parent.getItemAtPosition(position) Adapter, getItem

+3

String memberName=(YourObject)parent.getAdapter().get(postion).getName;

.

+1

Source: https://habr.com/ru/post/1620369/


All Articles