Android的PopupWindow使用android学习之旅(四十三)
来源:互联网 发布:网络枪战游戏排名 编辑:程序博客网 时间:2024/06/04 01:20
PopupWindow简介
PopupWindow是一个类似dialog的控件,可以接受任何的view作为下拉列表显示。
用法
代码展示
package peng.liu.test;import android.app.Activity;import android.app.AlertDialog;import android.content.DialogInterface;import android.os.Bundle;import android.view.Gravity;import android.view.View;import android.view.ViewGroup;import android.widget.ArrayAdapter;import android.widget.Button;import android.widget.ImageView;import android.widget.PopupWindow;import android.widget.TextView;public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); View root = this.getLayoutInflater().inflate(R.layout.cell,null); final PopupWindow popupWindow = new PopupWindow(root,280,360); findViewById(R.id.button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) {// popupWindow.showAsDropDown(view); popupWindow.showAtLocation(findViewById(R.id.button), Gravity.CENTER,20,20); } }); root.findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { popupWindow.dismiss(); } }); }}
<?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="match_parent"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button2" /></LinearLayout>
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" /></LinearLayout>
0 0
- Android的PopupWindow使用android学习之旅(四十三)
- Android的actionBar的菜单使用-android学习之旅(四十三)
- Android的TabHost组件-android的学习之旅(四十)
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记(四十):Preference的使用
- Android学习笔记四十三之Shape详解
- android学习之popupWindow
- Android学习之PopupWindow
- Android学习之PopupWindow
- Android之PopupWindow使用
- android之popupwindow使用
- 一---Android-SDK系列文章(6) ---JAVA 程序&& android应用程序(main函数)
- android中image文件的压缩与解压缩
- C语言 链表反向打印与反转
- mysql中You can't specify target table for update in FROM clause错误
- java 根据经纬度获取地址
- Android的PopupWindow使用android学习之旅(四十三)
- 流程自动化布局
- 在Activity中使用Fragment需要先集成FragmentActivity
- mysql查询数据库含有的表数量
- Linux命令工具 top详解
- 抱怨一发
- java 工具栏
- Word文档生成
- win7 JAVA Jdk安装与配置