標籤:android style blog http io ar os 使用 sp
PopupWindow的很多用法網上比較多,我就不做過多解釋了,只說下可能會遇到的問題,以及解決辦法:
1、PopupWindow中的listview無響應
這個主要是因為show寫在了setFocusable前面
2、點擊PopupWindow外面地區,不會自動dismiss
這個主要可能是沒有調用setBackgroundDrawable以及setOutsideTouchable,
當然了,你肯定還得寫響應監聽這個動作,如下面代碼
[java] view plaincopy
- <span style="font-family: ‘Microsoft YaHei‘; "><span style="font-size:18px;"> mPopupWindow.setTouchInterceptor(new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
- mPopupWindow.dismiss();
- Log.i("test", "test");
- return true;
- }
-
- return false;
- }
- });</span></span>
3、將預設的箭頭放到右邊
[java] view plaincopy
- <span style="font-family: ‘Microsoft YaHei‘; "><span style="font-size:18px;"> int width = getWindowManager().getDefaultDisplay().getWidth();
- mListView.setIndicatorBounds(width-40, width-10);</span></span>
- 上一篇Android 第三方應用接入平台(2)
- 下一篇Dialog的使用
【Android】 PopupWindow使用小結