点击ListView的每一个item,将弹出窗口显示item详情
主要代码:
private void openPopupwin() {
LayoutInflater mLayoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
ViewGroup rootView = (ViewGroup) mLayoutInflater.inflate(R.layout.person_info_pop, null, true);
TextView person_popup_name = (TextView)rootView.findViewById(R.id.person_popup_name);
TextView person_popup_realName = (TextView)rootView.findViewById(R.id.person_popup_realName);
TextView person_popup_age = (TextView)rootView.findViewById(R.id.person_popup_age);
TextView person_popup_birthday = (TextView)rootView.findViewById(R.id.person_popup_birthday);
TextView person_popup_phone = (TextView)rootView.findViewById(R.id.person_popup_phone);
TextView person_popup_deptId = (TextView)rootView.findViewById(R.id.person_popup_deptId);
Button btn_popup_close = (Button)rootView.findViewById(R.id.btn_popup_close);
ImageView person_popup_head = (ImageView)rootView.findViewById(R.id.person_popup_head);
try {
person_popup_name.setText(selectedperson.getString("name"));
person_popup_realName.setText(selectedperson.getString("realName"));
person_popup_age.setText(selectedperson.getString("age"));
person_popup_birthday.setText(selectedperson.getString("birthday"));
person_popup_phone.setText("13880012450");//还未添加字段
person_popup_deptId.setText("产品事业部");
person_popup_head.setBackgroundDrawable(ImageUtil.geRoundDrawableFromUrl(HttpUtil.BASE_URL+selectedperson.getString("headPhotoPath"), 10));
} catch (JSONException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
popupWindow = new PopupWindow(rootView, LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupWindow.setAnimationStyle(R.style.PopupAnimation);
popupWindow.showAtLocation(root, Gravity.CENTER | Gravity.CENTER, 0, 0);
popupWindow.update();
btn_popup_close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popupWindow.dismiss();
}
});
}
弹出窗口布局文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:gravity="center"
android:layout_height="wrap_content" android:layout_gravity="center" android:padding="5.0dip" android:layout_margin="5.0dip"
android:background="@drawable/popup_corner">
<RelativeLayout android:id="@+id/popup_top_bar" android:layout_alignParentTop="true" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:text="用户详细信息" android:textColor="#760606" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16.0sp" android:layout_alignParentLeft="true"/>
<Button android:id="@+id/btn_popup_close" android:background="@drawable/popup_close" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true"/>
</RelativeLayout>
<ImageView android:id="@+id/person_popup_head" android:scaleType="fitXY" android:layout_marginTop="5.0dip" android:layout_below="@id/popup_top_bar" android:layout_width="120.0dip" android:layout_height="120.0dip"/>
<TableLayout android:id="@+id/person_form" android:layout_marginLeft="2.0dip" android:layout_marginTop="5.0dip" android:layout_toRightOf="@id/person_popup_head" android:layout_below="@id/popup_top_bar" android:layout_width="wrap_content" android:layout_height="wrap_content">
<TableRow >
<TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="账号:"/>
<TextView android:id="@+id/person_popup_name" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</TableRow>
<TableRow >
<TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="姓名:"/>
<TextView android:id="@+id/person_popup_realName" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</TableRow>
<TableRow >
<TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="年龄:"/>
<TextView android:id="@+id/person_popup_age" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</TableRow>
<TableRow >
<TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="生日:"/>
<TextView android:id="@+id/person_popup_birthday" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</TableRow>
<TableRow >
<TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="电话号码:"/>
<TextView android:id="@+id/person_popup_phone" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:autoLink="phone"/>
</TableRow>
<TableRow >
<TextView android:layout_width="60.0dip" android:gravity="right" android:textColor="#074f92" android:layout_height="wrap_content" android:text="部门:"/>
<TextView android:id="@+id/person_popup_deptId" android:textColor="#074f92" android:layout_marginLeft="15.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
</RelativeLayout>
popup_enter.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale android:fromXScale="0.6" android:toXScale="1.0"
android:fromYScale="0.6" android:toYScale="1.0" android:pivotX="50%"
android:pivotY="50%" android:duration="1000" />
<alpha android:interpolator="@android:anim/decelerate_interpolator"
android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="1000" />
</set>
popup_exit.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:fromXScale="1.0"
android:toXScale="0.5"
android:fromYScale="1.0"
android:toYScale="0.5"
android:pivotX="50%"
android:pivotY="50%"
android:duration="500" />
<alpha
android:interpolator="@android:anim/accelerate_interpolator"
android:fromAlpha="1.0"
android:toAlpha="0.0"
android:duration="500" />
</set>
popup_corner.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<gradient android:startColor="#cbeafe" android:endColor="#ffffff" android:angle="90" />
<!--
<stroke android:dashWidth="2dp" android:dashGap="2dp" android:width="2dp" android:color="#FF00ff00"/>-->
<!--描边-->
<corners android:bottomRightRadius="5dp" android:bottomLeftRadius="5dp" android:topLeftRadius="5dp" android:topRightRadius="5dp" />
<!--设置圆角-->
</shape>
- 大小: 54.8 KB
分享到:
相关推荐
大家可自行学习,研究,并补充该demo.
分享一个在android开发中的多级PopupWindow 弹出窗口实例,不知道这种多级的弹出窗口算不算是“嵌套”方式?因为它们之间确实是有着层级的关系,当PopupWindow被主界面按钮触发的时候,会被弹出第一级,在第一级中...
自定义Spinner(PopupWindow实现的弹出下拉框),类似网站的下拉式窗口效果,封装好了,可以直接使用。。不用像自带的弹出式窗口难看。。。3分不贵
(1)Popupwindow在显示之前一定要设置宽高,Dialog无此限制。 (2)Popupwindow默认不会响应物理键盘的back,除非显示设置了popup.setFocusable(true);而在点击back的时候,Dialog会消失。 (3)Popupwindow不会...
jQuery实现弹出层窗口插件popupWindow.js.zip
主要介绍了Android开发实现popupWindow弹出窗口自定义布局与位置控制方法,涉及Android弹出窗口功能、布局及属性设置相关操作技巧,需要的朋友可以参考下
点击从底部弹出菜单,覆盖在当前Activity上面,背景灰色透明
安卓 Android PopupWindow浮动窗口实现实例,或者说是弹出窗口吧,总之就是地一类,在打开应用后,显示在最上层的一个浮动窗口效果,Andorid弹出窗口,Google为Andorid预置了几款默认的弹出窗口效果,本源码教你如何...
Android评论PopupWindow弹出窗,可根据输入法自适应高度,点击输入框时,输入法弹出和隐藏,对于我们的评论窗口而言,高度始终都是保持不变,这样可以给用户带来更好的体验! 具体实现代码地址:...
目前只见过两种弹出框的实现方式,第一种是最常见的PopupWindow,第二种也就是Activity的方式是前几天才见识过。感觉很霸气哦。没想到,activity也可以做伪窗口。 先贴上最常见的方法,主要讲activity的方法。 一、...
主要介绍了Android自定义弹出窗口PopupWindow使用技巧,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
自定义单选、多选对话框及popupwindow窗口实例源码是一个自定义的弹出对话框例子源码,弹出的时候有半透明效果,提供的有弹出单选(popwindow)、弹出多选(popwindow)、弹出单选(dialog)、弹出多选(dialog)等几种实现...
PopupWindow就是弹出窗口的意思,类似windows下面的开始按钮。PopupWindow可以实现浮层效果,而且可以自定义显示位置,出现和退出时的动画. 效果如下: 实现思路: 在一个PopupWindow里放一个ListView,从而来...
弹出窗口自动呈现和消失,并且不会干扰到用户的当前工作(不获得系统焦点),确实是一种友好的交互方式。 本系统是为Microsoft Visual Studio开发的一套弹出式窗体的模板,通过此模板,用户可以在自己的应用程序中...
http://blog.csdn.net/meetings/article/details/52972004 里面的ArsenalLayout是一个代码布局
PopupWindow,弹出框使用PopupWindow实现,这是点赞和评论的载体,具体要涉及 PopupWindow 点击非窗口位置和再次点击消失以及显示位置的问题(根据相应更多按钮的位置确定 PopupWindow 的显示位置 package ...
通过调整PopupWindow的背景色和透明度,我们可以轻松地创建出一个具有半透明效果的弹出窗口。 首先,你需要定义一个具有半透明效果的背景色。这通常是通过在颜色值中添加透明度(alpha)来实现的。例如,你可以使用...