小编Moj*_*oMS的帖子

android edittext单击按钮后删除焦点

我有一个带有EditText和Button的Activity.当用户点击EditText时,会显示键盘,他可以输入一些Text - fine.但是当用户点击按钮时,我希望EditText不再处于焦点状态,即键盘隐藏,直到用户再次点击EditText.

单击按钮后,我该怎么做才能"隐藏EditText的焦点".我可以在按钮的OnClick方法中添加一些代码来做到这一点?

编辑:

<LinearLayout 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <EditText 
        android:id="@+id/edt_SearchDest"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.8"
        android:textSize="18sp"
        android:hint="Enter your look-up here.." />

    <Button
        android:id="@+id/btn_SearchDest"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="0.2"
        android:text="Search" />

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

最好的祝福

android android-edittext

20
推荐指数
4
解决办法
5万
查看次数

如何从另一个模式引用 json 模式定义

我有一个 json 模式,将几何图形表示为点或多点。每个都是在“定义”中的模式中定义的:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "id": "http://schema.my-site.org/geometry.json#",
    "type": "object",
    "oneOf": [
        {
            "allOf": [
                {
                    "required": [
                        "type",
                        "coordinates"
                    ]
                },
                {
                    "oneOf": [
                        {
                            "$ref": "#/definitions/Point"
                        },
                        {
                            "$ref": "#/definitions/MultiPoint"
                        }
                    ]
                }
            ]
        }
    ],
    "definitions": {
        "Point": {
            "title": "Point",
            "type": "object",
            "properties": {
                "type": {
                    "enum": [
                        "Point"
                    ]
                },
                "coordinates": {
                    "$ref": "#/definitions/position"
                }
            }
        },
        "MultiPoint": {
            "title": "MultiPoint",
            "type": "object",
            "properties": {
                "type": {
                    "enum": [
                        "MultiPoint"
                    ]
                },
                "coordinates": {
                    "$ref": …
Run Code Online (Sandbox Code Playgroud)

json schema-design jsonschema

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

如何在javascript中使用http.post将图像发送到服务器并在mongodb中存储base64

我无法使用mongodb在客户端访问服务器端存储图像的http请求.我非常感谢你的帮助.我需要一个简单的例子,说明如何将图像文件作为数据添加到http post请求中,例如XMLhttprequest.可以说,我知道servermethod的url.图像的来源定义在

imgsrc
Run Code Online (Sandbox Code Playgroud)

存储文件的名称

name
Run Code Online (Sandbox Code Playgroud)

我有这个atm:

var http = new XMLHttpRequest();
httpPost.onreadystatechange = function(err) {
        if (httpPost.readyState == 4 && httpPost.status == 200){
            console.log(httpPost.responseText);
        } else {
            console.log(err);
        }
    }
var  path = "http://127.0.0.1:8000/uploadImage/"+name;
httpPost.open("POST", path, true);
// I guess I have to add the imagedata into the httpPost here, but i dont know how
httpPost.send(null);
Run Code Online (Sandbox Code Playgroud)

然后在路径的服务器端,将调用以下方法,我想在mongodb中存储base64编码图像的url.如何从httpPost访问图像?

function postNewImageType(req, res, next){
    var newImageTypeData = {
         name: req.params.name,
         image: "placeholder.png"
    }
    var data = // how to access the image?
    var …
Run Code Online (Sandbox Code Playgroud)

javascript base64 xmlhttprequest http-headers

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

如何在角度中多次生成相同的颜色样式?

在 Angular 中,我生成一个自定义主题文件、一个根样式文件,并且所有组件都有自己的自定义样式文件。但是,自从我更新到版本 10 后,我的终端就收到了垃圾邮件警告

WARNING: The same color styles are generated multiple times. Read more about how style duplication can be avoided in a dedicated guide. https://github.com/angular/components/blob/master/guides/duplicate-theming-styles.md
    node_modules/@angular/material/_theming.scss 1648:7  -mat-check-duplicate-theme-styles()
    node_modules/@angular/material/_theming.scss 7010:3  angular-material-theme()
    node_modules/@angular/material/_theming.scss 7061:3  angular-material-color()
    src/_custom_theme.scss 242:3                         @import
    stdin 2:9        
Run Code Online (Sandbox Code Playgroud)

按照指南,我可以将这个错误减少到至少四次到达。此错误列出了我的custom_theme 文件和我的node_modules 中的@angular/material。我真的想知道我做错了什么导致这个错误。在我的 custom_theme 的第 242 行,我正在生成我的深色主题.custom-dark-theme { @include angular-material-color($app-theme-dark); }

sass angular-material angular

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

如何在订阅方法中取消订阅 RXJS 订阅?

我有一些 javascript:

this.mySubscription = someObservable.subscribe((obs: any) => {
   this.mySubscription.unsubscribe();
   this.mySubscription = undefined;
}
Run Code Online (Sandbox Code Playgroud)

执行时,控制台会记录错误ERROR TypeError: Cannot read property 'unsubscribe' of undefined。我想知道为什么我不能在 subscribe lambda 函数中取消订阅。有正确的方法吗?我已经阅读了一些关于使用虚拟主题并完成它们或使用 takeUntil/takeWhile 和其他管道操作符 workArounds 的内容。

在订阅的订阅功能中取消订阅订阅的正确方法/解决方法是什么?

我目前正在使用一个虚拟订阅,如下所示:

mySubscription: BehaviorSubject<any> = new BehaviorSubject<any>(undefined);


// when I do the subscription:
dummySubscription: BehaviorSubject<any> = new BehaviourSubject<any>(this.mySubscription.getValue());
this.mySubscription = someObservable.subscribe((obs: any) => {
    // any work...
    dummySubscription.next(obs);
    dummySubscription.complete();
    dummySubscription = undefined;
}, error => {
    dummySubscription.error(error);
});

dummySubscription.subscribe((obs: any) => {
    // here the actual work to do when …
Run Code Online (Sandbox Code Playgroud)

rxjs rxjs-observables

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

为插值方法创建数据对象,例如R中的克里金法

我有不同位置(X1,X2,...)的温度数据的每日平均值,我想用它们插入地图.我通过从格式化的Excel工作表加载它们来创建长格式数据对象,例如:

library(reshape2)
tempdata <- read.csv("...", sep=";")
names(tempdata) <- c("date", paste("X", 1:73))
head(tempdata)
#    date  X1  X2  X3  X4  X5  X6  X7
# 1    1  7.3 6.6 6.7 5.8 6.1 6.1 5.5
# 2    2  7.5 6.6 6.6 5.6 4.8 4.7 3.9
# 3    3  8.8 7.7 7.6 7.0 7.0 6.0 5.8
# 4    4  8.5 7.4 7.5 7.0 7.3 5.9 5.5
# 5    5  7.7 6.7 6.9 6.1 6.8 5.1 4.1
# 6    6  7.5 6.7 6.8 6.0 6.4 5.0 …
Run Code Online (Sandbox Code Playgroud)

r spatial-interpolation spatial-data-frame

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

与mapquest的缩放级别相关的地图比例是什么?

在我的Android项目中我使用mapquest数据与OSMdroid.我想知道缩放级别提供的地图比例(例如1:10000等).我刚刚发现zoomlevel根据DPI进行缩放(地图的比例是否也取决于地图视图的宽度和高度,我正在展示?).如果我使用mapquest地图网站,我只会看到左下角的地图比例,但不是比例为1:10000,我实际需要.

什么是1:x在zoomlevel 16,15,14?

android osmdroid mapquest

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

WinHugs/Haskell中出现模糊的"map"错误

在WinHugs中,我实现了以下功能:

map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (x:l) = f x : map f l
Run Code Online (Sandbox Code Playgroud)

这应该只为列表中的每个数字运行一个函数,如:

Hugs> map (+ 1) [1,2,3]
Run Code Online (Sandbox Code Playgroud)

应该给

[2,3,4].
Run Code Online (Sandbox Code Playgroud)

但是当我尝试加载*.hs脚本时,WinHugs会给出错误消息

ERROR file:.\script.hs:3 - Ambiguous variable occurrence "map"
*** Could refer to: Main.map Hugs.Prelude.map 
Run Code Online (Sandbox Code Playgroud)

第3行是 map f (x:l) = f x : map f l

我该如何避免这个问题?我想我的偏好/设置中的某些内容是错误的.

haskell

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