Android開發,問題記錄

1、android TextView加載html 解決a標籤鏈接無效
關鍵在於setMovementMethod

tv_test.setText(charSequence);
tv_test.setClickable(true);
tv_test.setMovementMethod(LinkMovementMethod.getInstance());

2、popupWindow show()方法報錯
Unable to add window --token null is not valid; is your activity running?
解決方案:開線程或者在onWindowFocusChanged方法中show(推薦開線程)

guide_viewpager.post(new Runnable() {
                @Override
                public void run() {
                    mPopupWindow.showAtLocation(guide_viewpager, Gravity.CENTER, 0, 0);
                }
            });

3、popupwWindow的使用:

mView = LayoutInflater.from(this).inflate(R.layout.layout_pop_privocy, null, false);
mPopupWindow = new PopupWindow(mView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, true);
mPopupWindow.setOutsideTouchable(false);
mPopupWindow.setBackgroundDrawable(new BitmapDrawable(getResources(), (Bitmap) null));
mPopupWindow.showAtLocation(guide_viewpager, Gravity.CENTER, 0, 0);
發佈了33 篇原創文章 · 獲贊 2 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章