Skip to content Skip to sidebar Skip to footer

How To Get Custom Gird Child Item Click Event?

I am struggling with custom Gird view. Not exactly with Custom Gird view but its click event of child view. Major two query : first : issues is if i add simple image view and text

Solution 1:

in you getView for example

viewHolder.checkbox.setOnCheckedChangeListener(listenerCheckBox);

and listener

OnCheckedChangeListenerlistenerCheckBox=newOnCheckedChangeListener() {

        publicvoidonCheckedChanged(CompoundButton buttonView,
                boolean isChecked) {

        }
    };

and you item_grid for example

publicclassItem {

        privateString title;
        privateString description;
        privateDate pubDate;
        privateString link;

        publicItem(String title, String description, Date pubDate, String link) {
            this.title = title;
            this.description = description;
            this.pubDate = pubDate;
            this.link = link;
        }

publicStringgetTitle() {

returnthis.title;
}
publicStringsetTitle(String title_) {

this.title  = title_;
}

    }

\\\\\\\\\\\\\\\\\\\\

if you case

if (convertView == null) {
            view = new ViewHolder();
            convertView = inflator.inflate(R.layout.grid_item, null);

            view.imgViewFlag = (ImageView) convertView
                    .findViewById(R.id.imageView1);
            view.txt = (TextView) convertView
                    .findViewById(R.id.grid_item_label);
            view.btn1 = (Button) convertView.findViewById(R.id.button1);
            view.btn2 = (Button) convertView.findViewById(R.id.button2);



view.btn1.setOnClicListener(myClickListener);

            convertView.setTag(view);



        } else

\\\\\\\\\\\\\\\\\\\\\\\\

privateOnClickListenermyClickListener=newOnClickListener() {
        publicvoidonClick(View v) {


        }
    };

\\\\\\\\\\\\\\\\\\\\\\\

Post a Comment for "How To Get Custom Gird Child Item Click Event?"