自定义PopWindow,内部布局自定义
先上图:
这个PopWindow实现了弹出窗口,里面加载了列表(ListView),这里面的布局也可以自己定义,因为他本身就是个XML。
实现起来十分简单:
public void showPop(){
View popView = getLayoutInflater().inflate(R.layout.item_mypop,null);
ListView listView = (ListView) popView.findViewById(R.id.lv);
myAdapter.setData(data);
listView.setAdapter(myAdapter);
PopupWindow popupWindow = new PopupWindow(popView, 600,600);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F8F8F8")));
popupWindow.setFocusable(true);
popupWindow.setSplitTouchEnabled(true);
popupWindow.update();
popupWindow.showAtLocation(popView,Gravity.CENTER,0,0);
}
我们还可以给他加弹入弹出动画等等,这里就不一一枚举啦,使用起来是很简单的了