获取的layout可以自定义
lv_appmanager.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// TODO Auto-generated method stub
dismissPopUpwindow();
// 获取当前view对象在窗体中的位置
int[] arrayOfInt = new int[2];
view.getLocationInWindow(arrayOfInt);
int i = arrayOfInt[0] + 60;
int j = arrayOfInt[1];
AppInfo info = (AppInfo) lv_appmanager.getItemAtPosition(position);
View popupview = View.inflate(AppManagerActivity.this, R.layout.popup_item, null);
LinearLayout ll_start = (LinearLayout) popupview.findViewById(R.id.ll_start);
LinearLayout ll_uninstall = (LinearLayout) popupview
.findViewById(R.id.ll_uninstall);
LinearLayout ll_share = (LinearLayout) popupview.findViewById(R.id.ll_share);
// 把当前条目在listview中的位置设置给view对象
ll_share.setTag(position);
ll_uninstall.setTag(position);
ll_start.setTag(position);
ll_start.setOnClickListener(AppManagerActivity.this);
ll_uninstall.setOnClickListener(AppManagerActivity.this);
ll_share.setOnClickListener(AppManagerActivity.this);
LinearLayout ll = (LinearLayout) popupview.findViewById(R.id.ll_popup);
ScaleAnimation sa = new ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f);
sa.setDuration(200);
localPopupWindow = new PopupWindow(ll, WindowManager.LayoutParams.WRAP_CONTENT,
WindowManager.LayoutParams.WRAP_CONTENT);
// 一定要记得给popupwindow设置背景颜色
Drawable background = new ColorDrawable(Color.TRANSPARENT);
localPopupWindow.setBackgroundDrawable(background);
localPopupWindow.setAnimationStyle(R.style.PopupAnimation);
localPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, i, j);
// ll.startAnimation(sa);
}
});