1

I am developing an Application.

My layout is in my Previous Question.

For that I am using horizontal List view. In that I want to Get the position of the images while Scroll is changed.

I had tried for this:

hlv.setOnScrollStateChangedListener(new OnScrollStateChangedListener() {

            @Override
            public void onScrollStateChanged(ScrollState scrollState) {
                // TODO Auto-generated method stub

                for(int i=0;i<albumList.size();i++)
                {
                    if(hlv.callOnClick())
                    {
                        int id=i;
                        Toast.makeText(getApplicationContext(), ""+id, 1000).show();
                    }
                }
            }
        });

But didnt successed. I didnt got the position of element in the Variable.

Community
  • 1
  • 1
Pooja Roy
  • 545
  • 5
  • 25
  • http://stackoverflow.com/questions/8140623/android-onscrollstatechanged-scroll-state-idle-sometimes-doesnt-fire see this question once – Venu Apr 17 '14 at 10:30
  • What does your method `callOnClick()` do? Is it returning `true`? – Terry Apr 17 '14 at 10:30

1 Answers1

1

Did you tried the setOnItemClickListener for listview?. Even for a custom HorizontalListView it should be implemented as it is based on a normal ListView. Try it:

hlv.setOnItemClickListener(
     new OnItemClickListener()
     {
      public void onItemClick(AdapterView<?> arg0, View view, int position, long id) {
           Toast.makeText(this, "POSITION: "+position, Toast.LENGTH_SHORT).show();
       }
     }
  );

Hope it helps!

kodartcha
  • 1,063
  • 12
  • 23