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);

本文介绍了Android开发中的几个实用技巧,包括解决TextView加载HTML时a标签链接无效的问题,通过设置LinkMovementMethod来实现链接的点击功能;解决PopupWindow显示时的常见错误,推荐在onWindowFocusChanged方法中或使用开线程的方式进行PopupWindow的展示;以及详细的PopupWindow使用方法,包括布局设置、位置调整等。

被折叠的 条评论
为什么被折叠?



