小编spc*_*ial的帖子

硒和异步JavaScript调用

我对Selenium和JavaScript回调函数还很陌生,但有一个大问题我无法解决。我需要使用JavaScript的指定变量。如果我使用GoogleChrome打开页面并使用控制台输入我的JavaScript代码,则可以使用类似以下内容的变量:

1. var myId;
2. getSomeIdStuffInfo("somestuff",function(docId)(myId = docId));
3. return myId;
Run Code Online (Sandbox Code Playgroud)

如果我逐步输入此行,则很容易获得正确的值myId。但是,当然,如果我尽可能快地执行这三行,我将获得null作为返回值,因为当我返回myId时回调函数并未完成。SOOOO ..如果我像这样使用硒:

JavascriptExecutor js = (JavascriptExecutor) driver; 
    String docInfoVal = (String) js.executeScript("" +
            "var myId; " +
            "getCurrentDocumentInfo(\"somestuff\"," +
                "function(docId) {" +
                    "myId = docId;" +
                "}" +
            ");" +
            "return myId;");
Run Code Online (Sandbox Code Playgroud)

我只会得到null作为结果。所以...以某种方式我必须“等待”回调函数,直到我返回myId。我必须使用executeAsyncScript吗?我坐在上面几个小时,尝试了不同的方法,但是我找不到答案。

在此先感谢您的帮助!

javascript selenium asynchronous function callback

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

自定义 SearchView 建议布局

我使用教程SearchView在我ActionBar的地图中实现了一个:

实际上一切正常,但我唯一不喜欢的是带有搜索建议的黑框布局,请参见此处

如何自定义此布局(例如更改颜色、字体大小等)?

我试图为建议输出找到负责的代码块,但实际上我找不到它。欢迎任何帮助!

java android searchview google-maps-android-api-2

5
推荐指数
0
解决办法
297
查看次数

Android Studio渲染问题 - 缺少样式?

我在以下Preview窗口中收到以下错误Android Studio:

渲染问题缺少样式.是否为此布局选择了正确的主题?使用布局上方的主题组合框选择不同的布局,或修复主题样式引用.无法在当前主题中找到"?attr/actionBarPopupTheme".(4个类似错误未显示)

我创建了一个自定义样式/主题.这是关于styles.xml:

<resources xmlns:tools="http://schemas.android.com/tools" xmlns:android="http://schemas.android.com/apk/res/android">

    <style name="CustomActionBarTheme" parent="@style/Theme.AppCompat.Light">
        <item name="android:actionBarStyle"   tools:ignore="NewApi">@style/MyActionBar</item>
        <item name="actionBarStyle">@style/MyActionBar</item>
        <item name="actionBarTheme">@style/MyActionBarTheme</item>
    </style>

    <style name="MyActionBar" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="android:background"  tools:ignore="NewApi">@color/white</item>
        <item name="titleTextStyle">@style/MyActionBar.ActionBar.TitleTextStyle</item>
        <item name="background">@color/bg_common</item>
    </style>

    <style name="MyActionBarTheme" parent="@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
        <item name="actionMenuTextColor">@color/title</item>
        <item name="colorControlNormal">@color/title</item>
    </style>

    <style name="MyActionBar.ActionBar.TitleTextStyle" parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
        <item name="android:textColor">@color/title</item>
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

我的布局文件标题如下所示:

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    style="@style/CustomActionBarTheme"
    android:id="@+id/drawer_layout"
    android:background="@color/bg_common_2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

...
Run Code Online (Sandbox Code Playgroud)

在我的清单文件中,我在应用程序标记中添加了:

android:theme="@style/CustomActionBarTheme" 
Run Code Online (Sandbox Code Playgroud)

为什么我会收到错误?我也在CustomActionBarTheme预览窗口中选择了主题.我错过了什么吗?在此先感谢您的任何建议!

java xml android android-studio

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

如何计算/增加MS SQL选择中表列的当前出现次数

我有一张桌子,看起来像这样:

id | name| fk_something
----------------
0  | 25  | 3
1  | 25  | 2
2  | 23  | 1
Run Code Online (Sandbox Code Playgroud)

并且我想添加另一列,该列的编号在每次name出现行时都会递增,例如:

id | name| fk_something| n
--------------------------
0  | 25  | 3           | 1
1  | 25  | 2           | 2
2  | 23  | 1           | 1
Run Code Online (Sandbox Code Playgroud)

我不太确定如何实现这一目标。使用count()I只会得到的总发生次数,name但我想增加,n以便每行都有一个不同的值。

sql sql-server

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