android - Show menu in Google Glass -
hi having problem creating menu on regular cards in immersion. have far:
i have cardscrolladapter implements onitemclicklistener this:
private class examplecardscrolladapter extends cardscrolladapter implements onitemclicklistener {
@override public int findidposition(object id) { return -1; } @override public int finditemposition(object item) { return mcards.indexof(item); } @override public int getcount() { return mcards.size(); } @override public object getitem(int position) { return mcards.get(position); } @override public view getview(int position, view convertview, viewgroup parent) { view rowview = convertview; viewholder holder; if(rowview==null) { rowview = minflater.inflate(r.layout.card_layout, null); holder = new viewholder(); holder.maintext = (textview) rowview.findviewbyid(r.id.tvmaintext); holder.fullimage = (imageview) rowview.findviewbyid(r.id.fullimage); holder.image1=(imageview) rowview.findviewbyid(r.id.ivimage1); holder.image2 = (imageview) rowview.findviewbyid(r.id.ivimage2); holder.image3 = (imageview) rowview.findviewbyid(r.id.ivimage3); holder.llimages = (linearlayout) rowview.findviewbyid(r.id.llimages); holder.llsecondaryimages = (linearlayout) rowview.findviewbyid(r.id.llsecondaryimages); rowview.settag( holder ); } else holder = (viewholder) convertview.gettag(); customcard myobject = (customcard) getitem(position); if (myobject.getcompanyinfo()!=null) { system.out.println(myobject.getimageurl()); system.out.println(myobject.getcompanyinfo()); holder.maintext.settext(myobject.getcompanyinfo()); imageloader.displayimage(myobject.getimageurl(), holder.image1); holder.maintext.setvisibility(imageview.visible); holder.llimages.setvisibility(imageview.visible); holder.image1.setvisibility(imageview.visible); } else { imageloader.displayimage(myobject.getimageurl(), holder.fullimage); holder.llimages.setvisibility(imageview.visible); holder.fullimage.setvisibility(imageview.visible); } holder.image2.setvisibility(imageview.gone); holder.image3.setvisibility(imageview.gone); holder.llsecondaryimages.setvisibility(imageview.gone); return rowview; } public class viewholder { public textview maintext; public imageview fullimage; public imageview image1; public imageview image2; public imageview image3; public linearlayout llimages; public linearlayout llsecondaryimages; } public void onitemclick(adapterview<?> parent, view view, int position, long id) { system.out.println("click" + position); oncreateoptionsmenu(null); } }
and when tap cards prints "click" , position card works.
after want run oncreateoptionsmenu looks this:
@override public boolean oncreateoptionsmenu(menu menu) { menuinflater inflater = getmenuinflater(); inflater.inflate(r.menu.card_menu, menu); return true; }
the problem having understanding how make oncreateoptionsmenu run? menu menu must supply onitemclick method instead of null?
// joakim
you don't need separate activity case — should when need show menu live card.
the error in original onitemclick
method: should calling openoptionsmenu
display menu, not oncreateoptionsmenu
.
Comments
Post a Comment