/** * Created by renjianhong on 2016/3/24. */ public class TaskPopuWindow extends PopupWindow { private View popuView; private TextView contentTv,locationTv,timeTv; public TaskPopuWindow(final Activity context) { LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); popuView = inflater.inflate(R.layout.task_popu_window, null); contentTv = (TextView) popuView.findViewById(R.id.task_content); locationTv = (TextView) popuView.findViewById(R.id.task_location); if(!currentTaskContent.isEmpty()&&!currentTaskLocation.isEmpty()){ contentTv.setText(currentTaskContent); locationTv.setText(currentTaskLocation); } timeTv = (TextView) popuView.findViewById(R.id.task_time); // int w = context.getWindowManager().getDefaultDisplay().getWidth(); this.setContentView(popuView); // 设置SelectPicPopupWindow的View this.setContentView(popuView); // 设置SelectPicPopupWindow弹出窗体的宽 this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT); // 设置SelectPicPopupWindow弹出窗体的高 this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT); // 设置SelectPicPopupWindow弹出窗体可点击 } /** * 显示popupWindow * * @param parent */ public void showPopupWindow(View parent) { if (!this.isShowing()) { // 以下拉方式显示popupwindow Log.d("MainActivity","显示popupwindow方法被调用"); this.showAsDropDown(parent,0,10); } else { this.dismiss(); } }}
taskPopuWindow = new TaskPopuWindow(MainActivity.this); taskPopuWindow.showPopupWindow(waiterInfoLayout);
waiterInfoLayout是你所希望的popuwindow在其下方显示的控件
popuwindow使用
最新推荐文章于 2022-03-28 13:56:02 发布