简体   繁体   English

在Android 2.3中选择与Android 4.2不同的框样式

[英]Select box style in Android 2.3 different from Android 4.2

I am working on a PhoneGap app in which clicking on a button generates a specific number of text boxes and select boxes based on user's input. 我正在开发一个PhoneGap应用程序,其中单击按钮会生成特定数量的文本框,并根据用户的输入选择框。

I tested the app on an AVD running Android 4.2. 我在运行Android 4.2的AVD上测试了该应用程序。 Everything was working fine and the selectboxes generated along with text boxes looked as the image below: 一切正常,生成的选择框和文本框如下图所示:

Now, I tested the same app in an AVD running android 2.3 which gave me the output shown here: 现在,我在运行android 2.3的AVD中测试了相同的应用程序,它给了我这里显示的输出:

.

Clearly, the select box alone appears weird in Android 2.3 while the other controls like text box and buttons are absolutely fine. 显然,Android 2.3中的选择框似乎很奇怪,而文本框和按钮等其他控件绝对没问题。

I don't have any clue why this is happening. 我不知道为什么会发生这种情况。 The app uses JQM and Cordova 2.5.0. 该应用程序使用JQM和Cordova 2.5.0。

To give you some ground on what I am trying to explain, I have added the code below which is my select box markup 为了让你了解我想要解释的内容,我在下面添加了代码,这是我的选择框标记

    <select class="sel" data-theme="a" id="selectmenu0">
         <option value="1">option1</option>
         <option value="2">option2</option>
         <option value="3">option3</option>
    </select>

I resolved the issue myself. 我自己解决了这个问题。 The problem was with the way I generated the markup. 问题在于我生成标记的方式。 For some unknown reason, Android 2.3 expects the DOM to be built before navigating to the next page where the generated DOM will be inserted. 由于某些未知原因,Android 2.3期望在导航到将插入生成的DOM的下一页之前构建DOM。

But in my case, On receiving the input from the user, I did the following operations 但在我的情况下,在收到用户的输入后,我做了以下操作

  1. I navigated to the target page 我导航到目标页面
  2. Then, I built the select box markup 然后,我构建了选择框标记

For some reason, Android 2.3 expects the above steps to be in reverse order. 出于某种原因,Android 2.3期望上述步骤的顺序相反。 Only then, JQM applies it's styling to select box. 只有这样,JQM才会将它的样式应用于选择框。

I had the same problem and solved it by setting the parameter 'data-native-menu' to false, like this: 我遇到了同样的问题并通过将参数'data-native-menu'设置为false来解决它,如下所示:

<select id="yourSelectBox" data-native-menu="false"></select>

I think this is simpler. 我认为这更简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM