weidongjian / androidWheelView

仿照iOS的滚轮控件,从请吃饭apk反编译出来的

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

onSelectedItemClick

antoine1003 opened this issue · comments

Hey,
Is there anyway to create an even when the user click on the selected item?
Thanks

I find a trick for the ones who are looking for the same thing.

  1. Add private int position = -1; as a global variable in the .java of your view.
loopView.setListener(new OnItemSelectedListener() {
            @Override
            public void onItemSelected(int index) {
                if(position == index){
                    Toast.makeText(MainActivity.this, "item " + position + " name:" + list.get(position).toString(), Toast.LENGTH_SHORT).show();
                }
                else {
                    position = index;
                }
            }
        });

In that way, you'll have a onClickListenner

thanks a lot,i think this problem for a forenoon.