@Override public boolean onMenuItemClick(MenuItem popMenuItem) { final String itemId; switch (popMenuItem.getItemId()) { case R.id.editEvent: item = eventItemList.get(currentPosition); itemId = item.getObjectId(); openForm(itemId); return true; case R.id.deleteEvent: item = eventItemList.get(currentPosition); itemId = item.getObjectId(); new DialogBox() .dialog( activity, activity.getString(R.string.delete_item_title), activity.getString(R.string.delete_item_message), new DialogBox.CallBack() { @Override public void onFinished() { delete(itemId); } }); return true; case R.id.bidItem: new ItemBidHandler(activity, eventItemList, currentPosition).bidItem(); return true; default: return false; } }
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater listLayoutInflater = LayoutInflater.from(activity); convertView = listLayoutInflater.inflate(R.layout.event_details_items, null); } item = eventItemList.get(position); TextView itemName = (TextView) convertView.findViewById(R.id.event_details_item_name); itemName.setText(item.getName()); TextView itemDescription = (TextView) convertView.findViewById(R.id.event_details_item_description); itemDescription.setText(item.getDescription()); TextView previousBid = (TextView) convertView.findViewById(R.id.event_details_previous_bid); previousBid.setText(item.getPreviousBid().toString()); TextView newBid = (TextView) convertView.findViewById(R.id.event_details_new_bid); newBid.setText(item.getNewBid().toString()); final ImageView itemImage = (ImageView) convertView.findViewById(R.id.event_details_item_image); item.getImage() .getDataInBackground( new GetDataCallback() { @Override public void done(byte[] bytes, ParseException e) { Bitmap bitmap = BitmapFactory.decodeByteArray(bytes, 0, bytes.length); itemImage.setImageBitmap(bitmap); } }); ImageView moreActionButton = (ImageView) convertView.findViewById(R.id.popMenu); if (!isPlanner && !isEnteredEvent) moreActionButton.setVisibility(View.GONE); moreActionButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { currentPosition = position; showMenu(v); } }); return convertView; }