简单的弹窗应用(一)--PopupWindow
来源:互联网 发布:收纳 知乎 编辑:程序博客网 时间:2024/06/14 16:07
popupWindow就是弹窗
首先在布局写个按钮,点击事件里进行弹窗
tv.setOnClickListener(new OnClickListener() { private PopupWindow popupWindow; @Override public void onClick(View v) { // TODO Auto-generated method stub //布局加载器 LayoutInflater inflater = LayoutInflater.from(MainActivity.this); View view = inflater.inflate(R.layout.popitem, null); //加载布局内组件 LinearLayout llist = (LinearLayout) view.findViewById(R.id.llist); LinearLayout lgrip = (LinearLayout) view.findViewById(R.id.lgrip); //设置listview组件点击事件 llist.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub //跳转 Intent intent = new Intent(MainActivity.this,ListActivity.class); startActivity(intent); //弹窗消失 popupWindow.dismiss(); } }); //设置gridview组件点击事件 lgrip.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub //跳转 Intent intent = new Intent(MainActivity.this,GripActivity.class); startActivity(intent); //弹窗消失 popupWindow.dismiss(); } }); //设置弹窗大小和布局 popupWindow = new PopupWindow(view, 200, 280); //点击外部消失弹窗 popupWindow.setBackgroundDrawable(new ColorDrawable()); popupWindow.setOutsideTouchable(true); //显示在哪个布局下,放父组件 popupWindow.showAsDropDown(tv); } });
然后来看一下popupwindow的布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/llist" android:orientation="horizontal" android:padding="10dp" android:gravity="center" > <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="listview" /> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/lgrip" android:orientation="horizontal" android:padding="10dp" android:gravity="center" > <TextView android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Gridview" /> </LinearLayout></LinearLayout>
这样就可以弹窗了!!!
阅读全文
0 0
- 简单的弹窗应用(一)--PopupWindow
- Android开发之PopUpWindow的应用(一)
- Android中popupWindow的简单应用
- android PopupWindow 简单应用
- Android:PopupWindow简单弹窗
- 简单定制Android控件(3) - 打造通用的PopupWindow(一)
- PopupWindow弹出窗的简单实现
- popupwindow的应用
- PopupWindow(泡泡窗口)的简单实用
- PopupWindow的简单使用(结合RecyclerView)
- 简单的PopupWindow
- 简单的PopupWindow
- popupwindow的简单使用
- PopupWindow的简单用法
- PopupWindow的简单用法
- PopupWindow的简单使用
- PopupWindow 的简单使用
- PopupWindow的简单使用
- Linux的chomd命令
- C语言的变量的内存分配
- Latex 数学公式
- SSM轻松写出Restful风格接口
- 单项循环链表
- 简单的弹窗应用(一)--PopupWindow
- synchronized 的小测试
- 二维码的扫描
- java 类
- tableRow分栏
- 第三课 内存
- Jzoj5244 Daydreamin
- 用递归方法在有序表中二分查找(折半查找)
- Cordova入门