miércoles, 6 de agosto de 2014

Android: Popup menu

 private PopupWindow initiatePopupWindow(View anchor) {

  try {

   LayoutInflater layoutInflater = (LayoutInflater) getApplicationContext()
     .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   View layout = layoutInflater.inflate(R.layout.test_row, null);

   layout.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
   mainMenu = new PopupWindow(layout, FrameLayout.LayoutParams.MATCH_PARENT,
     FrameLayout.LayoutParams.WRAP_CONTENT, true);
   Drawable background = getResources().getDrawable(
     android.R.drawable.editbox_dropdown_dark_frame);
   mainMenu.setBackgroundDrawable(background);
   mainMenu.showAsDropDown(anchor, 0, 0);

   setOnClickListeners(layout);

  } catch (Exception e) {
   e.printStackTrace();
  }
  return mainMenu;

 }

No hay comentarios:

Publicar un comentario