标签: nativescript

NativeScript:如何设置listview itemTemplate的样式

我有以下NativeScript代码:

<Page loaded="onPageLoaded">
    <GridLayout rows="auto, *">
        <ListView items="{{ items }}" row="1">
            <ListView.itemTemplate >
                <Image url="{{ url }}" />
            </ListView.itemTemplate>
        </ListView>
    </GridLayout>
</Page>
Run Code Online (Sandbox Code Playgroud)

我想设置ListView-Item的样式,给它一个填充,这样每个图像周围都有一点空白.我尝试给它一个类并在css中设置类的风格,但我无法改变它.

然而,我能够为图像本身设置样式(给它一个余量).是否可以设置listviewItem容器的样式(就像我在css中设置div容器样式)?

css android listview class nativescript

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

如何调试nativescript代码?

我刚开始使用nativescript所以请注意这是否只是一个简单的问题.

在我的手机上运行我的代码tns run android,但是当它开始启动万吨洛也控制台,所以我如何调试自己编写的代码可以说我有console.log声明,我的代码,但我无法找到我的发言在这的很容易记录.

nativescript

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

带有nativescript的静态图

如何使用nativescript构建统计图表,我问是否有任何模块或教程或其他内容?

nativescript

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

Nativescript.任务执行失败':mergeF0DebugResources'

我收到以下异常执行失败的任务':mergeF0DebugResources.

运行'tns build android'或'tns运行android --emulator'时

tns版本:2.0.1 java版"1.8.0_92"

windows nativescript

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

如何在本机脚本中设置colorPrimary和colorPrimaryDark

在继续之前,我不得不说我已经阅读了很多与此有关的问题,并且任何解决方案都不适合我。我正在使用nativescript(v2.1.1),并且我尝试使用xml文件方法来更改状态栏和操作栏的颜色,但是我无法使其工作。这是我的尝试:

路径:app / App_Resources / Android / values / colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="ns_primary">#3f51b5</color>
    <color name="ns_primaryDark">#2137aa</color>
    <color name="ns_accent">#3f51b5</color>
</resources>
Run Code Online (Sandbox Code Playgroud)

路径:app / App_Resources / Android / values / styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
    <style name="AppThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>

        <item name="colorPrimary">@color/ns_primary</item>
        <item name="colorPrimaryDark">@color/ns_primaryDark</item>
        <item name="colorAccent">@color/ns_accent</item>
    </style>

    <style name="AppTheme" parent="AppThemeBase">
    </style>

    <style name="NativeScriptToolbarStyleBase" parent="Widget.AppCompat.Toolbar">
        <item name="android:background">@color/ns_primary</item>
        <item name="theme">@style/ThemeOverlay.AppCompat.ActionBar</item>
        <item name="popupTheme">@style/ThemeOverlay.AppCompat</item>
    </style>

    <style name="NativeScriptToolbarStyle" parent="NativeScriptToolbarStyleBase">
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

路径:app / App_Resources / Android / values-v21 / colors.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color …
Run Code Online (Sandbox Code Playgroud)

android statusbar nativescript

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

在输入字段模糊中隐藏Nativescript中的Android键盘

我有一个注册表单,其中包含几个TextFields和其他输入.当用户点击其中一个字段时,Android软键盘将始终按预期显示.如果我在外面拍打虽然键盘没有隐藏.有没有办法捕获此事件,以便当用户点击任何输入之外时我可以隐藏键盘?

看起来如下所示允许我隐藏键盘

var pageContainer = page.getViewById('registration-container');
if(pageContainer.android) {
    pageContainer.android.clearFocus();
}
Run Code Online (Sandbox Code Playgroud)

但我不确定如何捕捉模糊输入的每个点击事件.我甚至不确定Android是否可行.

javascript android nativescript

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

nativescript iOS Cocoa Pods 构建错误

当我尝试在 VS Code 中运行我的应用程序时,我最近开始收到一个奇怪的错误:

警告]:警告:CocoaPods 要求您的终端使用 UTF-8 编码。[31;1m 处理 node_modules 失败。异常:Pod 安装命令失败。错误输出:考虑将以下内容添加到 ~/.profile: export LANG=en_US.UTF-8

[NSDebugAdapter] tns 命令以代码 127 完成执行。

有人见过吗?我看到了建议的操作消息,但我不知道 ./profile 在哪里?

我在 El Capitan 上使用 tns 2.5.0 版和 VS Code

nativescript

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

如何使用Nativescript-Vue为动画分配元素?

查看此文档:

https://docs.nativescript.org/ui/animation

我正在尝试添加这个元素的类或ID <Label>来动画任何东西,但我不确定应该view通过直接用代码而不是CSS动画调用动画方法来分配一个元素来完全控制任何动画. Vue模板.

javascript nativescript nativescript-vue

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

使用Nativescript显示/隐藏密码文本

我想在登录表单中显示/隐藏密码文本。我有下面的代码。

我尝试以下代码:

    <GridLayout margin="10" verticalAlignment="center" backgroundColor="#ffffff">
        <StackLayout margin="10" verticalAlignment="center" [formGroup]="signUpForm" padding="15">
            <StackLayout class="input-field">
                <TextField formControlName="username" hint="Username"></TextField>
            </StackLayout>
            <StackLayout class="input-field">
                <TextField formControlName="password" hint="Password" secure="true">
                </TextField>
            </StackLayout>
            <Label text ="show/hide" (tap)="toggleShow()"></Label>
        </StackLayout>
   </GridLayout>
Run Code Online (Sandbox Code Playgroud)

在component.ts中,我编写了以下代码:

export class LoginComponent implements OnInit {
    signUpForm: FormGroup;
    show = false;
    type=  'password';
    constructor(....) {
        this.signUpForm = this.formBuilder.group({
            username: ["", Validators.required],
            password: ["", Validators.required]
        });
    }
    toggleShow()
    {
        this.show = !this.show;
        if (this.show){
            this.type = "text";
        }
        else {
            this.type = "password";
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我点击功能toggleShow()中 …

show-hide typescript nativescript angular2-nativescript angular

0
推荐指数
2
解决办法
1450
查看次数

角度:属性“ then”在“可观察”类型上不存在

我在这里使用Nativescript来构建移动应用程序。这里有错误。在我使用Visual Studio 2017进行ASP.Net MVC 5开发中,可以使用很好$http.get().then(),但在Nativescript中则不能。

请参见下面的代码:

import { Component, OnInit } from "@angular/core";
import { HttpClient } from '@angular/common/http';

@Component({
    selector: "Home",
    moduleId: module.id,
    templateUrl: "./home.component.html",
    styleUrls: ["./home.component.css"]
})
export class HomeComponent implements OnInit {

    constructor(private http: HttpClient) {
    }

    ngOnInit(): void {
        this.http.get('https://somewebsite.com',
            {
                params: { 'sorter': '', 'isAscending': 'true', 'searchString': '', 'currentPage': '1', 'itemsPerPage': '300' },
                headers: {
                    "Authorization": "Basic encryptedcodehere"
                }
            }).then(function (response) {
                var theData = JSON.parse(response.data);
                if (theData.Data != null && theData.Data.length > …
Run Code Online (Sandbox Code Playgroud)

nativescript angular

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