Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android GUI:输入整数的好UI模式是什么?_Android_User Interface - Fatal编程技术网

Android GUI:输入整数的好UI模式是什么?

Android GUI:输入整数的好UI模式是什么?,android,user-interface,Android,User Interface,我的UI中经常显示两个数字。我需要用户能够指定这些数字。在一个桌面应用程序中,我只需使用两个旋转按钮,就可以击败它(我猜)。然而,在Android系统中也存在一些问题(我的目标是基于Android 3的平板电脑) 首先,我尝试了NumberPicker小部件,但它并没有正确地显示出来(我尝试过,但到目前为止没有响应)。 然后,我尝试了一些第三方numberpicker的实现,在Web上可以找到,但出于各种原因,我不喜欢这两种实现。它们中的一些太大,无法容纳我正在挤压控件的侧面板,一些很难看(可能

我的UI中经常显示两个数字。我需要用户能够指定这些数字。在一个桌面应用程序中,我只需使用两个旋转按钮,就可以击败它(我猜)。然而,在Android系统中也存在一些问题(我的目标是基于Android 3的平板电脑)

首先,我尝试了NumberPicker小部件,但它并没有正确地显示出来(我尝试过,但到目前为止没有响应)。 然后,我尝试了一些第三方numberpicker的实现,在Web上可以找到,但出于各种原因,我不喜欢这两种实现。它们中的一些太大,无法容纳我正在挤压控件的侧面板,一些很难看(可能太小),并且它们都会自动抓住输入焦点,导致每次我打开侧面板时键盘都会显示出来。 还有另一个选项-仅在面板上显示带有数字的不可编辑标签,并显示带有一些数字图标的弹出窗口。除了我不知道如何实现这样一个弹出窗口(只是学习),我如何装饰标签,让用户了解他可以点击它进行编辑

也许,有更好的办法解决这个问题?我看了一下Google Market上的一些应用程序,它们似乎要么在屏幕中央使用巨大的数字图标(我需要尽可能多的屏幕清晰),要么在弹出窗口中使用我不太喜欢的巨大数字图标


你能提出其他建议吗?提前谢谢

您的问题中有两个不同的问题: 对于eaxmple的数字选择器(在我的例子中),我创建了一个简单的工具。您可以先放置一个文本为“-”的按钮,然后放置一个文本视图,再放置一个带有“+”的按钮。你把它放在一个线性布局中,t可以是垂直的,也可以是水平的。如果你想要它,你可以做得很小。例如,这里是我写的,但您可以尝试使用这些选项,看看哪个更适合您

<LinearLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="horizontal"
 android:layout_width="wrap_content" android:layout_height="wrap_content">

<LinearLayout android:orientation="vertical" android:id="@+id/linearLayout1"   
 android:layout_width="wrap_content" android:layout_weight="1" 
 android:layout_height="wrap_content">
    <Button android:id="@+id/button22" android:layout_gravity="center" 
 android:layout_weight="1" android:text="+" android:gravity="center"      
 android:layout_width="30dip" android:layout_height="30dip"></Button>
    <Button android:id="@+id/button11" 
    android:layout_gravity="center" 
    android:layout_weight="1" android:text="-" 
    android:gravity="center" android:textAppearance="?android:attr/textAppearanceSmall" android:layout_height="30dip" android:layout_width="30dip"></Button>
</LinearLayout>
    <LinearLayout android:id="@+id/linearLayout2" 
    android:layout_width="wrap_content" 
    android:layout_height="fill_parent" 
    android:layout_weight="1" android:orientation="vertical">
        <Button android:layout_weight="1" 
        android:layout_height="fill_parent" 
        android:layout_width="30dip"
        android:text="0" android:id="@+id/quantidad"></Button>
    </LinearLayout>

然后,您可以在按钮上添加onClick侦听器,并设置为增加或减少文本视图中显示的文本


至于键盘,如果您使用该示例,您不需要它,但如果您使用edittext,则可以设置一个选项,将键盘隐藏在清单中:您可以在此处看到该选项

如果数字超过2位,最快的方法是使用带数字过滤器的常规编辑字段。当键盘显示时,它应该以数字模式显示。常规编辑有两个问题:每次在屏幕上显示时,它都会抓住焦点(试图与之抗争,但迄今为止运气不佳),而且它没有+/-按钮来快速调整数字。但是,不知道这是否对用户过期至关重要。首先检查靠近edti文本的布局xml,您将看到一些“请求焦点”删除它,它应该可以解决问题problem@vallllll当前位置我做了,但没帮上什么忙。更重要的是,我现在正在以编程方式创建文本编辑,问题仍然存在。这正是我所尝试的。问题是我不想禁用KB,我只需要在用户点击编辑时弹出。