Onclick Listener Gridview Does Not Work In Fragment
I have 3 fragments with gridview but onclikitem event does not work. What might be the problem? I did my best and I tried all of them but not true. I think the problem is the use o
Solution 1:
I think you have to change in your adapter like below.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder listViewHolder;
if(convertView == null){
listViewHolder = new ViewHolder();
convertView = layoutinflater.inflate(R.layout.pop_music_list, parent, null);
listViewHolder.screenShot = (ImageView)convertView.findViewById(R.id.screen_shot);
listViewHolder.musicName = (TextView)convertView.findViewById(R.id.music_name);
listViewHolder.musicAuthor = (TextView)convertView.findViewById(R.id.music_author);
convertView.setTag(listViewHolder);
}else{
listViewHolder = (ViewHolder)convertView.getTag();
}
listViewHolder.screenShot.setImageResource(listStorage.get(position).getScreenShot());
listViewHolder.musicName.setText(listStorage.get(position).getMusicName());
listViewHolder.musicAuthor.setText(listStorage.get(position).getMusicAuthor());
return convertView;
}
put null
in place of false
at where you inflate your view.
Post a Comment for "Onclick Listener Gridview Does Not Work In Fragment"