I am developing an app like google Play Music! the thing is like that app i have a popupmenu for each row on my gridview. I'm setting grid view adapter from fragment which implements onClickListener. question is: how can i set onclicklistener for each popupmenu and handle onclick event from fragment my popupmenu contains two items : DELETE Add to playList
the reason i want to access onClick from fragment is i want to delete the specific file and update grid view with notifydatasetchanged() !
how can i do this or any suggestion for how can i delete the specific file from adapter n update grid view!
thanks!
this is my GridView Adapter :
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
ViewHolder holder;
item = songs.get(position);
if (row == null) {
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
row = inflater.inflate(com.irangrammy.irangrammy.R.layout.mchannel_row, parent, false);
holder = new ViewHolder();
holder.thumbnail = (ImageView) row.findViewById(com.irangrammy.irangrammy.R.id.image);
holder.title = (TextView) row.findViewById(com.irangrammy.irangrammy.R.id.singer);
holder.mMenu = (ImageView) row.findViewById(R.id.itemOption);
holder.mMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
PopupMenu popUp = new PopupMenu(context, v);
MenuInflater inflater = popUp.getMenuInflater();
inflater.inflate(R.menu.mchannel_popup, popUp.getMenu());
popUp.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem arg0) {
// TODO Auto-generated method stub
if(arg0.getItemId()==R.id.delete)
{
}
return true;
}
});
popUp.show();
}
});
row.setTag(holder);
} else {
holder = (ViewHolder) row.getTag();
}