小编der*_*erM的帖子

ListView,高亮选中的项目

我在我的活动中创建了一个 ListView,另外两个按钮(上一个,下一个)用于在 ListView 上移动一个突出显示。当单击这两个按钮时,我调用 setSelection(pos),但列表视图上没有高亮显示。

我还尝试使用布局文件自定义列表项,并在其上注册选择器,如:http : //android-codes-examples.blogspot.com/2011/03/customized-listview-items-selection.html

不幸的是,它没有按预期工作。当我触摸列表项时,此方法确实更改了颜色,但是当我调用 setSelection() 时没有突出显示。

layout/main.xml(主布局):

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="4"
    >
    <ListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1" />
    <LinearLayout
        android:orientation="vertical"
        android:weightSum="2"
        android:layout_width="match_parent"
        android:layout_height="fill_parent"
        android:layout_weight="3">
        <Button
            android:id="@+id/btn_prev"
            android:text="prev"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" />
        <Button
            android:id="@+id/btn_next"
            android:text="next"
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" />
    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

List.java(活动):

package com.android.list;

import android.app.Activity;
import android.os.Bundle;

import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.TableRow;
import android.widget.SimpleAdapter;
import android.widget.SimpleAdapter.ViewBinder;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.graphics.Point;
import android.graphics.Color; …
Run Code Online (Sandbox Code Playgroud)

android listview

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

Pinterest API停止工作

我们在过去1.5年内为客户提供Pinterest Pin调度功能.我们突然开始收到错误回复"我们最终出了问题.抱歉." 从今天开始.

我已经尝试过Pinterest API资源管理器并获得相同的错误消息.奇怪的是,虽然我们收到一条错误信息,但Pin是用破碎的图像创建的.即https://in.pinterest.com/pin/573434965041286865/,当我们尝试直接在浏览器中打开图像URL时,即https://s-media-cache-ak0.pinimg.com/originals/d0/ad/c8 /d0adc8520559848912b22f392eb339c1.jpg,它显示Access Denied错误.

是否有任何API更改或任何其他问题?我们目前将图像作为image_url参数传递.我们已经尝试使用图像参数将图片作为multipart/form发送,但是我们得到了相同的错误.

这是我们要求的样本.

网址:https://api.pinterest.com/v1/pins/?access_token =&fields = id%2Clink%2Cnote%2Curl

表格数据:image_url:http://d1ttb7iswciaye.cloudfront.net/wp-content/uploads/2015/06/slide1_img.png 注意:向前迈出一步,然后再向前迈出一步.如果你继续向前迈出一小步,这一切都是可能的#ows #success #possible board:573435033743083706

另外,有没有办法连接到Pinterest支持?他们在https://developers.pinterest.com/support/contact/上提供的帮助也无效.

pinterest

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

具有“经典”旋转盒显示的自定义旋转盒

我需要使用 double ,spinboxQML view这种情况下,我基于spinbox示例

SpinBox {
    id: spinbox
    from: 0
    value: 110
    to: 100 * 100
    stepSize: 100
    anchors.centerIn: parent

    property int decimals: 2
    property real realValue: value / 100

    validator: DoubleValidator {
        bottom: Math.min(spinbox.from, spinbox.to)
        top:  Math.max(spinbox.from, spinbox.to)
    }

    textFromValue: function(value, locale) {
        return Number(value / 100).toLocaleString(locale, 'f', spinbox.decimals)
    }

    valueFromText: function(text, locale) {
        return Number.fromLocaleString(locale, text) * 100
    }
}
Run Code Online (Sandbox Code Playgroud)

似乎当您使用自定义旋转框时,它不会显示为“经典”旋转框。显示如下:

在此输入图像描述

但是,按钮对于我的界面来说太大了。我想知道是否有一种简单的方法可以将旋转框显示为“经典”旋转框,如下所示:

在此输入图像描述

qt qml qspinbox qtquickcontrols2

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

设置 Qml TabBar 选项卡颜色?

我尝试使用此代码设置 TabBar 选项卡背景颜色,但仅更改了选定的选项卡颜色。如何为其他标签设置颜色?另外,如何设置选项卡的文本颜色?

TabBar {
    id: tabBar

    currentIndex: swipeView.currentIndex

    background: Rectangle {
        color: "#f4d37c"
    }

    TabButton {
        id: cardsTabButton
        height: Style.line2Height
        text: qsTr("Cards")
    }

    TabButton {
        id: errorsTabButton
        height: Style.line2Height
        text: qsTr("Errors")
    }
}
Run Code Online (Sandbox Code Playgroud)

代码结果 (左侧选项卡被选中)

qml

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

如何在 QML 中为 TableView 创建自定义滚动条?

我想在 TableView 中自定义 ScrollBar。
我可以在 ListView 和 GridView 中自定义 ScrollBar,但无法对 TableView 执行相同操作。

我发现这是因为GridView和ListView继承自Flickable而TableView继承自ScrollView。有什么替代方案吗?

TableView {
    id:songGrid
    TableViewColumn {
        role: "title"
        title: "Title"
        width: 100
    }
    TableViewColumn {
        role: "author"
        title: "Author"
        width: 200
    }


    ScrollBar.horizontal:  ScrollBar {
        id: scrollBar2
        anchors.bottom:  songGrid.bottom
        //            anchors.bottomMargin: 70*downscaleFactor
        width: 5
        active: true
        visible:songGrid.moving?true:false

        contentItem: Rectangle {
            id:contentItem_rect2
            width:100
            implicitHeight:4
            radius: implicitHeight/2
            color: "Red"
        }
    }

    model: libraryModel1
}


ListModel {
    id: libraryModel1
    ListElement {
        title: "A Masterpiece"
        author: "Gabriel"
    }
    ListElement {
        title: "Brilliance" …
Run Code Online (Sandbox Code Playgroud)

qt qt-creator tableview qml

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

在QML中使用模型的大小

我正在寻找一种方法来访问QML中模型中可以找到的元素数量.

例如:

Item {
    id: root
    Row {
        id: row
        height: root.height
        width: root.width
        spacing: 5
        Repeater {
            id: rep
            width: root.width
            height: root.height
            model: [5, 3, 3, 1, 12]
            delegate: myDelegate
            Text {
                id: myDelegate
                text: "Element " + index + " of " size + ":" + modelData
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但我无法弄清楚如何检索模型的大小.在文档中,我可以找到一个名为的属性count,但没有提示如何访问它.

qt qml qtquick2

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

QML中相互依赖属性的双向绑定

在学习 QML 时,我偶然发现了一个问题,即我必须拥有相互依赖的属性。

例如,用户可以使用滑块设置一个值,或者使用文本输入来输入它。
移动滑块时,应更新 textinput 中的文本,而在 textinput 中输入值时,需要调整滑块位置。

现在我有两个属性:滑块的 x 值和文本输入中的文本。我需要将它们转换为相同的格式(例如:百分比),反之亦然。设置两个绑定会导致绑定循环,这可能不是一件好事。

我认为,这是一个非常普遍的问题,所以我确信有一些“黄金标准”可以解决它。但是我找不到合适的解决方案。

我想到的唯一方法是根本不使用绑定,而是处理信号,其中一个值已手动更改(如果我无法覆盖 C++ 中的 setter)。
你能做的只有这些吗?

祝你有美好的一天!
-m-

编辑:我现在尝试将滑块的值有条件地绑定到百分比值。

对象handle是滑块上的标记,handleArea是附加到它的鼠标区域,允许拖动。

Binding {
    target: root
    property: 'percent'
    value: handle.x / handleBar.width
    when: handleArea.drag.active
}

Binding {
    target: handle
    property: 'x'
    value: root.percent * handleBar.width
    when: !handleArea.drag.active
}
Run Code Online (Sandbox Code Playgroud)

有用。但这是一种好的风格吗?

qt qml

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

QML Listview 和 c++:ReferenceError 模型未定义

我想ListView在 QML 中将我的 C++ 类显示为 a。我有一个空向量,稍后将被填充:

QList<QObject*> _myList;
Run Code Online (Sandbox Code Playgroud)

并设置上下文

QQmlContext *ctxt = _eng->rootContext();
ctxt->setContextProperty("modelName",QVariant::fromValue(_myList));
Run Code Online (Sandbox Code Playgroud)

在 qml 文件中我有

ListView {
    id: listView
    model: modelName
    delegate: myDelegate {}
}
Run Code Online (Sandbox Code Playgroud)

但是启动应用程序时出现以下错误

qrc:/screen2.qml:252: ReferenceError: modelName is not defined
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?奇怪的是,该错误并不会阻止列表在填满后正确显示。

c++ qt listview qml

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

带有 Spring AutoConfiguration 的库: spring.factories 还有什么?

我们打算开发一个带有 Spring 组件的库,我们所有的 Spring 应用程序都应该具有这些组件,例如连接到我们的监控、管理和管理服务的 Bean。

这个想法是利用 Springs 的“自动配置”机制。

对于初学者,我编写了一个类com.mycorp.project.basic.startup-notification.StartupNotificationPublisher.class,当“ApplicationStartedEvent”发生时,它通过我们最喜欢的消息代理(例如,它是一个日志文件)发送一条消息,向世界问好。

应通过配置类创建此类的实例com.mycorp.project.basic.startup-notification.autoconfiguration.StartupNotificationAutoConfiguration.class

package com.mycorp.project.basic.startup-notification
// ... Imports
@RequiredArgsConstructor
public class StartupNotificationPublisher {
    private final String topic;

    private final Logger messagePublisher = LoggerFactory.getLogger(StartupNotificationPublisher.class);

    @EventListener
    public void onApplicationStartedEvent(ApplicationStartedEvent event) {
        messagePublisher.info("{}: Hello, Attention, I am here!", topic);
    }
}

package com.mycorp.project.basic.startup-notification.autoconfiguration
// ... Imports
@Configuration
public class StartupNotificationAutoConfiguration {

    @ConditionalOnMissingBean
    @Bean
    StartupNotificationPublisher startupNotificationPublisher()
    {
        return new StartupNotificationPublisher("helloTopic");
    }
}
Run Code Online (Sandbox Code Playgroud)

最后,为了使自动配置工作,我spring.factoriesMETA-INFjar 的 -Folder 中放置了一个文件(是的,它就在那里!),其中包含:

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

4
推荐指数
2
解决办法
7422
查看次数

ORA-01830:日期格式图片在TOAD中转换整个输入字符串之前结束

我有一个脚本,用于编写函数和过程。该脚本在Oracle SQL Developer中绝对正常,没有任何错误或警告。我必须将此脚本提供给客户端客户。客户用户在其中运行相同的脚本TOAD,他得到错误消息

ORA-01830: date format picture ends before converting entire input string

在这种情况下,我真的不知道如何处理此类错误。这是错误TOAD吗?我在函数中使用to_dateto_timestamp,但出现错误。

oracle datetime toad function to-date

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