小编laz*_*guy的帖子

使用jquery解析html字符串

我试图通过jQuery解析这个html来获取data1,data2,data3.虽然我确实获得了data2和data3,但我无法使用我的方法获取data3.我是jQuery的新手所以请原谅我的无知.

<html>
<body>
   <div class="class0">
    <h4>data1</h4>
    <p class="class1">data2</p>
    <div id="mydivid"><p>data3</p></div>    
   </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是我在jquery中调用它的方式.

var datahtml = "<html><body><div class=\"class0\"><h4>data1</h4><p class=\"class1\">data2</p><div id=\"mydivid\"><p>data3</p></div></div></body></html>";

alert($(datahtml).find(".class0").text()); // Doesn't Work

alert($(datahtml).find(".class1").text()); // work 

alert($(datahtml).find("#mydivid").text()); // work
Run Code Online (Sandbox Code Playgroud)

只有alert($(datahtml).find(".class0").text());不工作,其余的工作正如预期的那样.我想知道它可能是因为class0里面有多个标签或者是什么?如何在这种情况下获取data1?

jquery

35
推荐指数
2
解决办法
9万
查看次数

用于Android和启动画面的Phonegap构建适用于平板电脑

注意:这是android建议调整屏幕大小的方式所以我使用phonegap来构建应用程序.我有正在显示的启动画面,并在config.xml中列出.

<gap:splash src="splash/android/ldpi.png" gap:platform="android" gap:density="ldpi" />         <gap:splash src="splash/android/mdpi.png" gap:platform="android" gap:density="mdpi"/>
<gap:splash src="splash/android/hdpi.png"  gap:platform="android" gap:density="hdpi" />
<gap:splash src="splash/android/xhdpi.png" gap:platform="android" gap:density="xhdpi" />
Run Code Online (Sandbox Code Playgroud)

问题是,当我在我的三星galaxy skyrocket 2手机上测试它时会显示"hdpi.png"图像,当我在三星Galaxy 10英寸平板电脑上测试它时会显示mdpi.png图像.

这不应该是另一种方式吗?

基于android规范(见上图)我的mdpi.png大小为320x480,hdpi.png为480x800,因此mdpi.png在平板电脑中出现了拉伸.

怎么解决这个问题?你认为我应该为mdpi定义多个初始屏幕尺寸,例如普通屏幕32x480,大屏幕480x800等.但是如果我们采用这种方法,那么如何在config.xml中定义它?因为我们只根据间隙进行过滤:density ="mdpi"或者我们是否应该添加尺寸,因此在同一间隙中添加多个条目:density ="mdpi"

android cordova

6
推荐指数
1
解决办法
1921
查看次数

无法通过maven jaxb插件生成注释

我试图将javax.persistence.Id添加为字段的注释,并通过Maven JAXB插件生成Java对象.但是我遇到javax.persistence.id的类找不到异常我确实确保javax.persistence包含在maven依赖项中,我看到maven将它作为依赖项,但是当我运行jaxb插件时它将无效.

  1. 这是我的XML <xsd:complexType name="MyTable"> <xsd:sequence> <xsd:element name="id" type="xsd:int"/> </xsd:sequence> </xsd:complexType>
  2. 这是我的binding.xjb文件
<jaxb:bindings version="2.1"
   xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
   xmlns:xs="http://www.w3.org/2001/XMLSchema"
   xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
   xmlns:annox="http://annox.dev.java.net" jaxb:extensionBindingPrefixes="annox">

<jaxb:bindings schemaLocation="mytable.xsd">

  <jaxb:bindings node="xs:complexType[@name='MyTable']/xs:sequence/xs:element[@name='id']">
       <annox:annotate target="field">
             <annox:annotate annox:class="javax.persistence.Id"/>
       </annox:annotate>
  </jaxb:bindings> 

</jaxb:bindings>
Run Code Online (Sandbox Code Playgroud)

  1. 这是我的相关Pom.xml

    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.9</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics</artifactId>
            <version>0.6.4</version>
        </dependency>
        <dependency>
            <groupId>org.jvnet.jaxb2_commons</groupId>
            <artifactId>jaxb2-basics-annotate</artifactId>
            <version>0.6.4</version>
        </dependency>
        <dependency>
         <groupId>javax.persistence</groupId>
         <artifactId>persistence-api</artifactId>
         <version>1.0.2</version>
         <scope>provided</scope>
    </dependency>
     </dependencies>
    
     <build>
        <plugins>
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.8.3</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <configuration>
                            <forceRegenerate>true</forceRegenerate>
                            <schemaDirectory>myschema</schemaDirectory>
                            <bindingIncludes>
                                <include>binding.xjb</include>
                            </bindingIncludes>
                            <extension>true</extension>
                           <args>
                            <arg>-Xvalue-constructor</arg>
                            <arg>-XtoString</arg>
                            <arg>-Xequals</arg>
                            <arg>-XhashCode</arg>
                            <arg>-Xcopyable</arg> …
    Run Code Online (Sandbox Code Playgroud)

xsd maven-3 jpa-2.0 maven-jaxb2-plugin jaxb2-maven-plugin

2
推荐指数
1
解决办法
6267
查看次数

在android中以编程方式插入选项时设置保持唤醒状态

我正在尝试以编程方式在Android的"设置"中的"开发者选项"下设置"保持清醒"复选框.

我正在使用以下代码

Settings.Global.putInt(this.getContentResolver(),Settings.Global.STAY_ON_WHILE_PLUGGED_IN, 0);  
Run Code Online (Sandbox Code Playgroud)

我在我的清单文件中添加了两个权限.

 <uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
 <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"></uses-permission>
Run Code Online (Sandbox Code Playgroud)

我正在使用android 4.2.2在eclipse中编译项目,然后在我的平板电脑上运行,该平板电脑具有Android 4.1.2

当我运行apk崩溃时,我在Logcat中看到了这个异常.

E/AndroidRuntime(6596):java.lang.NoClassDefFoundError:android.provider.Settings $ Global

有什么问题的建议或如何实现上述功能?非常感谢!

java android

2
推荐指数
1
解决办法
1669
查看次数

在Eclipse Mobile Juno中安装"Android M2e"插件或基本上"适用于M2E 0.4.2的Android配置器"

尝试在http://rgladwell.github.com/m2e-android/上安装Android M2e插件,但没有运气.我得到了"Android Configurator for M2E 0.4.2"的例外情况

无法完成安装,因为找不到一个或多个必需的项目.正在安装的软件:适用于M2E 0.4.2的Android配置器(me.gladwell.eclipse.m2e.android.feature.feature.group 0.4.2)缺少要求:适用于M2E 0.4.2的Android配置器(me.gladwell.eclipse.m2e. android.feature.feature.group 0.4.2)需要'org.eclipse.persistence.moxy 2.1.0',但无法找到

我正在使用Eclipse Juno for Mobile Developers.我试过"Eclipse IDE for Java EE Developers",它也给了我同样的错误.

这是我的日食信息

Eclipse for Mobile Developers版本:Juno Release Build id:20120614-1722

我也直接访问了github上的插件网站https://github.com/rgladwell/m2e-android/blob/master/me.gladwell.eclipse.m2e.android.feature/feature.xml,发现它需要以下插件

<requires>
      <import plugin="org.eclipse.core.runtime"/>
      <import plugin="org.eclipse.jdt.core" version="3.5.1" match="greaterOrEqual"/>
      <import plugin="org.eclipse.core.resources" version="3.5.0" match="greaterOrEqual"/>
      <import plugin="org.eclipse.jdt.launching" version="3.5.0" match="greaterOrEqual"/>
      <import plugin="org.eclipse.core.filesystem" version="1.2.0" match="greaterOrEqual"/>
      <import plugin="org.eclipse.ui.console" version="3.4.0" match="greaterOrEqual"/>
      <import plugin="org.eclipse.persistence.moxy" version="2.1.0" match="greaterOrEqual"/>
      <import plugin="javax.xml.bind"/>
      <import plugin="org.eclipse.osgi"/>
      <import feature="org.eclipse.m2e.feature" version="1.0.200.20111228-1245"/>
      <import feature="com.android.ide.eclipse.adt" version="17.0.0.v201203161636-291853"/>
   </requires>
Run Code Online (Sandbox Code Playgroud)

有谁知道如何安装org.eclipse.persistence.moxy插件?我怀疑这必须与其他一些插件捆绑在一起.任何帮助赞赏.

android eclipse-plugin m2eclipse maven-plugin

1
推荐指数
1
解决办法
1825
查看次数