Android中PopupWindow实现弹窗输入的效果
来源:互联网 发布:安卓必备软件 编辑:程序博客网 时间:2024/05/29 12:21
前面一段时间做一个app,里面有EditText控件,但是输入的信息量较多,所有不是特别方便。因此想实现点击EditText之后,弹一个框,在里面输入要输入的内容,也方便修改,下面是实现的步骤:
我在实现的时候,重写了PopupWindow这个类:
我在实现的时候,重写了PopupWindow这个类:
public class PopWindowUtils extends PopupWindow{private EditText mPopWindowEditText = null;private Button mButton = null;private View mView = null;private LayoutInflater mLayoutInflater = null;public PopWindowUtils(Activity activity){mLayoutInflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);mView = mLayoutInflater.inflate(R.layout.popwindow, null);mPopWindowEditText = (EditText)mView.findViewById(R.id.mPopWindowEditText);mButton = (Button)mView.findViewById(R.id.mButton);this.setContentView(mView);this.setWidth(LayoutParams.FILL_PARENT);this.setHeight(180);this.setFocusable(true);//this.setAnimationStyle(android.R.anim.slide_in_left);//this.update();mButton.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {MainActivity.onTextChanged(mPopWindowEditText.getText().toString());dismiss();}});}}
然后再主Activity中设置了一个回调方法:
public static void onTextChanged(String text){ mEditText.setText(text); }在主Activity中的EditText点击弹出PopupWindow:
mEditText.setOnClickListener(new View.OnClickListener() {public void onClick(View v) {mEditText.setFocusable(false);mPopupWindow = new PopWindowUtils(MainActivity.this);mPopupWindow.showAtLocation(MainActivity.this.findViewById(R.id.main), Gravity.TOP | Gravity.LEFT, 0, 0);}});
0 0
- Android中PopupWindow实现弹窗输入的效果
- android中实现透明悬浮的PopupWindow效果
- Android自定义popupwindow实现ios中UC浏览器中长按图片弹出的PopupWindow效果
- PopupWindow实现弹窗效果
- Android中popupwindow的实现
- Android 自定义PopupWindow实现悬浮窗效果
- android 自定义菜单 使用PopupWindow实现菜单的各种效果
- android中实现自动输入文本效果
- android popupwindow的实现
- Android实现PopupWindow 弹窗效果 可用于提示信息等
- Android实现PopupWindow 弹窗效果 可用于提示信息等
- Android PopupWindow介绍及实现菜单效果
- [Android实例] popupwindow实现弹出菜单效果
- Android PopupWindow介绍及实现菜单效果
- Android PopupWindow介绍及实现菜单效果
- Android PopupWindow介绍及实现菜单效果
- Android开发技术学习之popupwindow的弹窗实现
- Android开发技术学习之popupwindow的弹窗实现
- 九度1448:Legal or Not
- 排序(1)
- [黑马程序员]多线程_平时工作多用匿名类
- 2014ACM集训13级PK赛5-Faster, Higher, Stronger
- 旱冰场照价
- Android中PopupWindow实现弹窗输入的效果
- SIGIR论文写作技巧
- [蓝桥杯历届试题] 欧拉与鸡蛋
- 2014年华中科技大学计算机研究生复试机试题目
- 利用classLoader加载src下面的文件
- 每天一小步,成功一大步
- Python简单抓取原理引出分布式爬虫
- android导入
- JSP中的pagaEncoding和contentType中charset的区别