PopupWindow
来源:互联网 发布:node书推荐 编辑:程序博客网 时间:2024/06/10 00:40
ublic class MainActivity extends Activity implements OnClickListener{
Button bt_pop;
PopupWindow pw;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bt_pop=(Button) findViewById(R.id.bt_popwindow);
bt_pop.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bt_popwindow:
LayoutInflater mLayoutInflater=(LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View menuView=mLayoutInflater.inflate(R.layout.popup_car, null, true);
pw=new PopupWindow(menuView, LayoutParams.FILL_PARENT, LayoutParams.MATCH_PARENT, true);
pw.setContentView(menuView);
Button btnAddAttention=(Button) menuView.findViewById(R.id.btn_public_car);
btnAddAttention.setText("添加关注");
Button btnCancleAttention=(Button) menuView.findViewById(R.id.btn_add_friend);
btnCancleAttention.setText("取消关注");
Button btnFeedBack=(Button) menuView.findViewById(R.id.btn_feed_back);
btnFeedBack.setVisibility(View.GONE);
btnAddAttention.setOnClickListener(this);
btnCancleAttention.setOnClickListener(this);
menuView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
pw.dismiss();
}
});
// pw.setHeight(height)//设置屏幕大小的高度
pw.setBackgroundDrawable(getResources().getDrawable(R.drawable.icon_popup_backgroud));
pw.setOutsideTouchable(false);
pw.setFocusable(true);
pw.showAsDropDown(menuView);
pw.update();
break;
case R.id.btn_add_friend:
Toast.makeText(getApplicationContext(), "取消关注", 0).show();
break;
case R.id.btn_public_car:
Toast.makeText(getApplicationContext(), "添加关注", 0).show();
break;
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/popup_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ffffff"
android:orientation="vertical"
android:paddingBottom="40dp">
<Button
android:id="@+id/btn_public_car"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="30dp"
android:background="@drawable/orange_roundbtn_selector"
android:text="发布车辆"
android:textColor="@color/white"
android:textSize="18sp" />
<Button
android:id="@+id/btn_add_friend"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="@drawable/orange_roundbtn_selector"
android:text="添加好友"
android:textColor="@color/white"
android:textSize="17sp" />
<Button
android:id="@+id/btn_feed_back"
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:background="@drawable/orange_roundbtn_selector"
android:text="意见反馈"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 普通按钮的选择器 用于界面上按下前是橘色,按下后是暗橘色的按钮 -->
<item android:drawable="@drawable/icon_orange_dark_button" android:state_pressed="true"></item>
<item android:drawable="@drawable/icon_orange_dark_button" android:state_enabled="false"></item>
<item android:drawable="@drawable/icon_orange_button"></item>
</selector>
- popupwindow
- popupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- popupwindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- PopupWindow
- popupwindow
- popupwindow
- PopupWindow
- 快速幂求余
- Kali 2.0 使用 Reaver 的注意事项
- 外部css文件背景图片引入路径问题
- web.xml中配置404等错误页面
- CodeForces--609C --Load Balancing(水题)
- PopupWindow
- Java设计模式——单例设计模式
- oracle中实现截取字符串(substr)、查找字符串位置(instr)、替换字符串(replace)
- 堆和栈区别 生长方向
- 基础算法(一):Random Ferns分类器原理及其应用
- 迪克斯特拉(Dijkstra)算法之MATLAB实现
- [CODECHEF]COUNTARI
- 无名数学题1(国王奇遇记减弱版)
- Linux TOP 命令详述