小编Sea*_*rzi的帖子

以编程方式设置 RippleDrawable 角半径

我在RippleDrawable下面创建了一个喜欢。但是我无法更改 RippleDrawable 的圆角半径。它没有像setCornerRadii(float[] f).

public static RippleDrawable getPressedColorRippleDrawable(int normalColor, int pressedColor) {
    if (Build.VERSION.SDK_INT>=21) {
        RippleDrawable rippleDrawable = new RippleDrawable(getPressedColorSelector(normalColor, pressedColor), getColorDrawableFromColor(normalColor), null);
        //rippleDrawable.setRadius((int) Manager.convertDpToPixel(5));
        return rippleDrawable;
    }
    else
        return null;
}
Run Code Online (Sandbox Code Playgroud)

其他功能是

public static ColorStateList getPressedColorSelector(int normalColor, int pressedColor) {
    return new ColorStateList(
            new int[][]
                    {
                            new int[]{android.R.attr.state_pressed},
                            new int[]{android.R.attr.state_focused},
                            new int[]{android.R.attr.state_activated},
                            new int[]{}
                    },
            new int[]
                    {
                            pressedColor,
                            pressedColor,
                            pressedColor,
                            normalColor
                    }
    );
}

public static ColorDrawable getColorDrawableFromColor(int color) {
    return new ColorDrawable(color);
} …
Run Code Online (Sandbox Code Playgroud)

android drawable rippledrawable

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

RealmList<String> 包含指定值

我有一个名为的 RealmObject Activity:

public class Activity extends RealmObject {

    @PrimaryKey
    public String token;
    public RealmList<String> names;
    public RealmList<String> units;
    public RealmList<Float> points;
}
Run Code Online (Sandbox Code Playgroud)

查询时,我想返回Activity其names列表中包含某个值的所有项目。(不是 a exactly matches,很像 SQLlike语句。)

我试过

val allActivities = realm.where(Activity::class.java).contains("names", str).findAllAsync()
Run Code Online (Sandbox Code Playgroud)

但我有一个例外:

java.lang.IllegalArgumentException:无效查询:类“Activity”中的字段“names”的类型无效“STRING_LIST”。

我试过如何查询具有包含指定值的 RealmList 的 RealmObject,但上述类型RealmList是扩展RealmObject,而String不是。有什么想法吗?

android realm

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

一次将多个项目添加到WooCommerce购物车

我有3个要添加到购物车中的不同商品的ID。我可以使用,https://url.com/shop/cart/?add-to-cart=3001但是当我想添加3个项目时,我做不到。我可以添加任何功能/脚本来将此功能添加到购物网站吗?

我尝试在之后添加&,add-to-cart并尝试添加新值,但是GET被覆盖了吗?: https://url.com/shop/cart/?add-to-cart=3001&add-to-cart=2002&add-to-cart=1001

php woocommerce

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

Swift 中的“nonisolated”关键字是什么?

我最近在 Swift 中遇到了nonisolated以下代码中的关键字:

actor BankAccount {

    init(balance: Double) {
        self.balance = balance
    }

    private var balance: Double

    nonisolated func availableCountries() -> [String] {
        return ["US", "CA", "NL"]
    }

    func increaseBalance(by amount: Double) {
        self.balance += amount
    }

}
Run Code Online (Sandbox Code Playgroud)

它有什么作用?无论有没有它,代码都可以编译。

actor swift

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

防止 Android 中的材质按钮升起

如您所知,API+21 中的按钮在您触摸时会升起。根据文档,您不应将此类按钮放置在对话框或其他凸起界面中。我尝试将海拔设置为 0 或 1 但无济于事。我只是希望按钮具有连锁反应而不升高。我怎样才能做到这一点?

<Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:elevation="0dp"
            android:clickable="true"/>
Run Code Online (Sandbox Code Playgroud)

android

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

keyboardWillShow在eventFirstResponder之后没有立即调用通知

我已实施keyboardWillShow:和keyboardWillHide:通知.我正在注册通知,直接触摸屏幕后它们工作正常UITextField,但是有问题.在viewDidLoad注册我正在通知的通知后,在我的右边becomeFirstResponder.键盘弹出,但keyboardWillShow:没有被调用(如上所述,只是第一次.从你调用函数注册通知的时间和实际注册的时间似乎有一个延迟,我不应该延迟执行becomeFirstResponder).有任何想法吗?

@objc func keyboardWillShow(_ notification: NSNotification) {
    print("Show")
    if let keyboardSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue {
        var userInfo = notification.userInfo!
        var keyboardFrame:CGRect = (userInfo[UIKeyboardFrameBeginUserInfoKey] as! NSValue).cgRectValue
        keyboardFrame = self.view.convert(keyboardFrame, from: nil)
        var contentInset: UIEdgeInsets = self.tv_main.contentInset
        contentInset.bottom = keyboardSize.height
        self.tv_main.contentInset = contentInset
        let indexpath = IndexPath(row: 0, section: 0)
        self.tv_main.scrollToRow(at: indexpath, at: UITableViewScrollPosition.top, animated: true)
    }
}

@objc func keyboardWillHide(_ notification: NSNotification) {
    print("Hide")
    if let …
Run Code Online (Sandbox Code Playgroud)

ios swift

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

标签 统计

android ×3

swift ×2

actor ×1

drawable ×1

ios ×1

php ×1

realm ×1

rippledrawable ×1

woocommerce ×1