Code example for ListView

Methods: setAdapter, setOnItemClickListener

0
        } 
 
        preShow(); 
 
        MenuItemAdapter adapter = new MenuItemAdapter(mContext, mItems);
        mItemsView.setAdapter(adapter);
        mItemsView.setOnItemClickListener(new OnItemClickListener() {
 
             
            public void onItemClick(AdapterView<?> parent, View view, int position,
                    long id) {
                if (mListener != null) {
                    mListener.onItemSelected(mItems.get(position));
                } 
                mPopupWindow.dismiss();
            } 
        }); 
 
        if (anchor == null) {
            View parent = ((Activity)mContext).getWindow().getDecorView();
            mPopupWindow.showAtLocation(parent, Gravity.CENTER, 0, 0);