public class TopPopup extends PopupWindow{
private LayoutInflater inflater;
private LinearLayout layout;
private ListView listItem;
private String[] StrItems;
private ArrayAdapter
private Context mContext;
public TopPopup(Context context) {
super(context);
mContext = context;
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layout = (LinearLayout) inflater.inflate(R.layout.bottom_popup,
null);
setContentView(layout);
// 设置弹出窗体的宽
this.setWidth(200);
// 设置弹出窗体的高
this.setHeight(LayoutParams.WRAP_CONTENT);
// 设置弹出窗体可点击
this.setFocusable(true);
// 设置弹出窗体动画效果
this.setAnimationStyle(R.style.MainPopupAnim);
listItem = new ListView(context);
layout.addView(listItem);
}
public void show(View parent) {
///显示在制定控件的下方
this.showAsDropDown(parent);
adapter = new ArrayAdapter
listItem.setAdapter(adapter);
}
public void setItems(String [] items){
StrItems = items;
}
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setListNavigationCallbacks(adapter,new DropDrowListener());