List of usage examples for android.widget PopupWindow PopupWindow
public PopupWindow(int width, int height)
Create a new empty, non focusable popup window.
From source file:com.tcl.lzhang1.mymusic.ui.MusicListAcitivity.java
/** * //ww w. j a v a2s . com */ private void showListMore() { if (null != moreMenu) { moreMenu.dismiss(); moreMenu = null; return; } moreMenu = new PopupWindow(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // moreMenu.setBackgroundDrawable(new ); moreMenu.setOutsideTouchable(false); moreMenu.setBackgroundDrawable(new ColorDrawable(Color.WHITE)); moreView = getLayoutInflater().inflate(R.layout.activity_music_scan_more, null); music_list_more = (ListView) moreView.findViewById(R.id.music_list_more); moreStringArray = getResources().getStringArray(R.array.music_list_more); mMoreAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, moreStringArray); music_list_more.setAdapter(mMoreAdapter); music_list_more.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // TODO Auto-generated method stub if (null != moreMenu) { moreMenu.dismiss(); } switch (position) { case 0: /* * Log.d(TAG, "sort by song"); new Thread(new Runnable() * { * @SuppressWarnings("unchecked") * @Override public void run() { // TODO Auto-generated * method stub List<SongModel> models = null; if * (curStartMode == START_MODE_LOCAL) { models = * (List<SongModel>) mDbOperator * .findAll("select * from songs order by name"); } else * if (curStartMode == START_MODE_FAV) { models = * (List<SongModel>) mDbOperator * .findAll("select * from songs where fav=1 order by name " * ); } if (null != models) { Message message = * mHandler.obtainMessage(); message.what = 2; * message.obj = models; mHandler.sendMessage(message); * } } }).start(); */ mMusicList.setPullLoadEnable(true); orderCol = "name"; loadData(1, UIHelper.PAGE_SIZE, UIHelper.LISTVIEW_ACTION_REFRESH, "name", mHandler); break; case 1: /* * Log.d(TAG, "sort by singer"); new Thread(new * Runnable() { * @SuppressWarnings({ "unchecked" }) * @Override public void run() { // TODO Auto-generated * method stub List<SongModel> models = null; if * (curStartMode == START_MODE_LOCAL) { models = * (List<SongModel>) mDbOperator * .findAll("select * from songs order by singername"); * } else if (curStartMode == START_MODE_FAV) { models = * (List<SongModel>) mDbOperator .findAll( * "select * from songs where fav=1 order by singername" * ); } if (null != models) { Message message = * mHandler.obtainMessage(); message.what = 2; * message.obj = models; mHandler.sendMessage(message); * } } }).start(); */ mMusicList.setPullLoadEnable(true); orderCol = "singername"; loadData(1, UIHelper.PAGE_SIZE, UIHelper.LISTVIEW_ACTION_REFRESH, "singername", mHandler); break; case 2: UIHelper.showScanMusicActivity(MusicListAcitivity.this, null); break; default: break; } } }); moreMenu.setContentView(moreView); moreMenu.showAsDropDown(more); }
From source file:com.lykj.weixun.ui.chat.ui.ContactListFragment.java
public void setPopuWindow(View view) { // //from ww w . java 2 s . co m View inflateView = LayoutInflater.from(getContext()).inflate(R.layout.popu_meu, null); // window = new PopupWindow(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); window.setTouchable(true); window.setFocusable(true); window.setBackgroundDrawable(new BitmapDrawable());//?? // window.setContentView(inflateView); // popWindow???true int[] location = new int[2]; inflateView.getLocationOnScreen(location); window.setOutsideTouchable(true); window.showAsDropDown(view);//v? window.showAtLocation(inflateView, Gravity.NO_GRAVITY, location[0] + inflateView.getWidth() - 20, location[1]); inflateView.findViewById(R.id.popuMeu_group).setOnClickListener(this); inflateView.findViewById(R.id.popuMeu_friend).setOnClickListener(this); inflateView.findViewById(R.id.popuMeu_sweep).setOnClickListener(this); window.setTouchInterceptor(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // popupwindowpopupwindow // true?touch // ? PopupWindowonTouchEvent?dismiss if (event.getAction() == MotionEvent.ACTION_OUTSIDE) { window.dismiss(); return true; } return false; } }); }