国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 系統(tǒng) > Android > 正文

Android popupWindow彈出窗體實(shí)現(xiàn)方法分析

2019-10-22 18:32:24
字體:
供稿:網(wǎng)友

本文實(shí)例講述了Android popupWindow彈出窗體實(shí)現(xiàn)方法。分享給大家供大家參考,具體如下:

1. 建立popupwindow顯示的布局頁(yè)面(普通的view任意布局)

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_width="match_parent"  android:layout_height="80dip"  android:background="@drawable/popup_yellow_window_bg"  android:orientation="horizontal" >  <TextView      android:id="@+id/popupwindow_app_uninstall_text"      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_gravity="center_horizontal"      android:layout_marginBottom="5dip"      android:layout_marginTop="5dip"      android:drawableTop="@drawable/kn_malware_scan_deep_click"      android:text="卸 載"/></LinearLayout>

2. activity中布局加載以及填充,建立popupwindow對(duì)象,設(shè)置相應(yīng)參數(shù)或?qū)傩?/p>

View contentView = View.inflate(getApplicationContext(), R.layout.popup_window, null);LinearLayout ll_uninstall = (LinearLayout) contentView.findViewById(R.id.ll_uninstall);//設(shè)置popupwindow內(nèi)布局組件的監(jiān)聽(與其他組件相似)MyOnClickListener l = new MyOnClickListener(position);ll_uninstall.setOnClickListener(l);PopupWindow mPopupWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.WRAP_CONTENT, 70);int[] arrayOfInt = new int[2];view.getLocationInWindow(arrayOfInt);int x = arrayOfInt[0] + 60;int y = arrayOfInt[1];//1 指定popupwindow的背景  2 popupwindow能夠獲得焦點(diǎn)mPopupWindow.setBackgroundDrawable(new BitmapDrawable());mPopupWindow.setFocusable(true);mPopupWindow.showAtLocation(view, Gravity.LEFT|Gravity.TOP, x, y);//在合適位置取消popupwindow顯示mPopupWindow.dismiss();

希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。


注:相關(guān)教程知識(shí)閱讀請(qǐng)移步到Android開發(fā)頻道。
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 塘沽区| 林甸县| 张家港市| 永济市| 佛冈县| 无极县| 溧阳市| 榆社县| 蓬安县| 澄江县| 济宁市| 长汀县| 车致| 墨玉县| 灵宝市| 二手房| 沈丘县| 静宁县| 厦门市| 海晏县| 公主岭市| 赣州市| 渑池县| 修武县| 米易县| 衡水市| 友谊县| 吴桥县| 轮台县| 中宁县| 志丹县| 邯郸县| 房山区| 高台县| 崇仁县| 河北省| 高邮市| 汶川县| 五原县| 宜川县| 山丹县|