我应该使用一个PopupWindow或DialogFragment接受输入? [英] Should I use a PopupWindow or DialogFragment for accepting input?

查看:1064
本文介绍了我应该使用一个PopupWindow或DialogFragment接受输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个弹出 3纱厂和一个EditText。阅读许多博客和文章,我不能决定哪个是最好的选择,之后的 PopupWindow DialogFragment

I am doing a Popup with 3 Spinners and an EditText. After reading many blogs and articles I can't decide which is the best option, PopupWindow or DialogFragment.

该标准将是:

  1. 兼容性与不同的Andr​​oid的版本
  2. 性能
  1. Compatibility with different Android's versions
  2. Performance

如果有更好的方法来做到这一点,我打开改变角度。

If there is a better way to do it I am open to change the perspective.

非常感谢你。

DialogFragment:

DialogFragment:

  • 优点:
  • 缺点:

PopupWindow:

PopupWindow:

  • 优点:
  • 缺点:

编辑:结论

DialogFragment 允许您使用更复杂的功能。另一个重要的事情是,它是更多平板电脑友好的,因为它可以让用户打开了多个片段的时间。片段是一个更加动态的解决方案,它们是新的Andr​​oid版本的标准。

DialogFragment allows you to use more complex features. Another important thing is that it is more tablet-friendly as it lets user to have opened more than one fragment at a time. Fragments are a more dynamic solution and they are the standard for newer Android versions.

PopupWindow 是简单,它是简单的问题给用户。

PopupWindow is simpler and it is very helpful on simple questions to the user.

推荐答案

支持库可以给你一个 DialogFragment 这是与旧版本的Andr​​oid兼容。来吧与片段对话,因为你在问什么是pretty的specifical(3纺纱厂和一个EditText只需右键点击Android的工具项目和preSS - >添加支持库 确保当您使用对话框导入

The support library can give you a DialogFragment which is compatible with old versions of android. Go ahead with the fragment dialog cuz what you're asking is pretty specifical (3 spinners and an edittext. Just right click your project and press on "Android tools" --> "Add support library" Make sure when you use the dialog to import

import android.support.v4.app.DialogFragment;

否则,你将使用对话框,但不支持结束:P。你将不得不与对话的片段,并使用您认为合适(自己做,甚至一个布局)的观点毫不费力的权力更大的灵活性。

Else you'll end up using the dialog without the support :P. You will have more flexibility with the dialog fragment and the power to use the view you see fit (even a layout made by yourself) without much effort.

对话片段

优点:

  • 在有能力添加任何看法
  • 易于修改
  • 可适应在横向或纵向的片剂或手机只是通过修改布局
  • 能奉献一个全新的类只是修改它自己的方式

缺点:

  • Cosumes更多内存的更复杂的是你的看法
  • 更难code

弹出窗口:

优点:

  • 简单
  • 更容易code
  • 这是多个标准因此这将是很难为用户与它
  • 混淆

缺点:

  • 更简单,这意味着在它的控制较少
  • 仅限于少数几个模板

这些只是从我的脑海顶部,从我的经验,但你应该阅读文档

These are just from the top of my mind and from my experience, but you should read the documentation

<一个href="http://developer.android.com/reference/android/widget/PopupWindow.html">http://developer.android.com/reference/android/widget/PopupWindow.html

<一个href="http://developer.android.com/reference/android/app/DialogFragment.html">http://developer.android.com/reference/android/app/DialogFragment.html

这篇关于我应该使用一个PopupWindow或DialogFragment接受输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆