0

I have a Listview, which have images text and a small image. on click of item it goes in Detailview.

On click of big image Small List view layout should change to different and on 2nd click should retain the list view content.

on click of small image it should get the position of item click and than should call a different method with item position.

Please help got stuck badly

Appoorva Faldu
  • 344
  • 4
  • 17

2 Answers2

5

Try this it will help

    holder.childview.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub


        //add code for child click


        }
    });




        convertView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub



        //add code for entire convert view for adapter  



        }
    });


         // add click event from activity

              //And create OnClickListener Object in Your activity and pass
         it in your baseAdapter constuctor and use it like this.

             convertView.setOnClickListener(onClickListener);

    }

//like this sample object

private OnClickListener onClickListener= new View.OnClickListener() {

    @Override
    public void onClick(View v) {


         // put your code here
        }

};
kiran boghra
  • 3,662
  • 2
  • 18
  • 23
  • Thanks guys but my Main problem is that i cant call it from the Adapter Class i need to call this from Main Acitivty Class of list and wanna make use of it on setonitemclicklistner. So how to add such code in Activity Class – Appoorva Faldu Nov 29 '13 at 11:53
1

In your adapter, in the getView method:

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    // use viewholder pattern here

    imageView.setTag(position)
    imageView.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(final View v) { 
           int position = v.getTag();
           // do something with position here
        } 
    }

  }

I have not tested this code, but I suppose it should work.

Tobrun
  • 18,291
  • 10
  • 66
  • 81
  • Thanks guys but my Main problem is that i cant call it from the Adapter Class i need to call this from Main Acitivty Class of list and wanna make use of it on setonitemclicklistner. So how to add such code in Activity Class – Appoorva Faldu Nov 29 '13 at 11:53