nClickListener (new View.OnClickListener () {
@ Overridevoid onClick (View view) {.dismiss ();
} popupWindow;
} ArrayList lt; String gt; getHumanReadableHeaders () {[] headers=this.getResources (). getStringArray (R.array.quality_headers); lt; String gt; humanReadableHeaders=new ArrayList lt; String gt; (); sizesCount=pictureSizes.length; (int i=0; i lt; 3; i ++) {(i lt; sizesCount) {.Size size=pictureSizes [i] ;. add (. format (% s (% dx% d) raquo ;, headers [i], size.width, size.height));
} else {;
} humanReadableHeaders;
} void setPopupListContent (ListView list, final ArrayList lt; String gt; humanReadableHeaders) {array=getTheme (). obtainStyledAttributes (int [] {android.Rtr.listPreferredItemHeightSmall}); array!=null; int height=array.getDimensionPixelSize (0, - 1) ;. recycle ();
//Extended adapter is needed to set equal width to all items in pop up list.
//It s supposed that the first row is the widest one (and it s true).
//It s obvious that such solution can cause bugs with list item s size.
//Unfortunately there is no other way to simulate action bar drop down behaviour..setAdapter (ArrayAdapter lt; String gt; (this, .layout.quality_list_item, .id.headerTextView,) {int maxWidth=0 ;
@ OverrideView getView (int position, View convertView, ViewGroup parent) {view=super.getView (position, convertView, parent); view!=null; (position == 0) {.measure ( View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);=view.getMeasuredWidth ();
} else {.setLayoutParams (new ListView.LayoutParams (maxWidth, height));
} view;
} PopupWindow getPopupWindow (View view, int width, int height) {popupWindow=new PopupWindow (view, width, height, true);
//noinspection deprecation.setBackgroundDrawable (new BitmapDrawable ()) ;. setTouchable (true) ;. setOutsideTouchable (true); popupWindow;
}
//endregion
}