小编Par*_*lke的帖子

Android 模拟器 30.4.5 不适用于 MacOS

系统信息

MacOs 版本 - 11.3 测试版

Android Studio 版本 - 4.1.2

Android 模拟器版本 - 30.4.5

Android HAXM 版本 - 7.5.1

错误堆栈

emulator: Android emulator version 30.4.5.0 (build_id 7140946) (CL:N/A)
handleCpuAcceleration: feature check for hvf
cannot add library /Users/rajaparikshit/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libvulkan.dylib: failed
HVF error: HV_ERROR
qemu-system-x86_64: failed to initialize HVF: Invalid argument
Failed to open the hax module
No accelerator found.
qemu-system-x86_64: failed to initialize HAX: Operation not supported by device
added library /Users/rajaparikshit/Library/Android/sdk/emulator/lib64/vulkan/libvulkan.dylib
cannot add library /Users/rajaparikshit/Library/Android/sdk/emulator/qemu/darwin-x86_64/lib64/vulkan/libMoltenVK.dylib: failed
added library /Users/rajaparikshit/Library/Android/sdk/emulator/lib64/vulkan/libMoltenVK.dylib
Run Code Online (Sandbox Code Playgroud)

Android …

android-emulator android-studio-4.1 macos-big-sur

23
推荐指数
2
解决办法
6418
查看次数

将参数传递给方法的Android数据绑定

首先,这个问题不是'onClick'事件参数传递的情况。

我有一种方法与DateUtil类,如下所示:

public static String formatDate(long date) {
        SimpleDateFormat dateFormat;
        dateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
        Calendar c = Calendar.getInstance();

        dateFormat.setTimeZone(TimeZone.getDefault());
        c.setTimeInMillis(date);
        return dateFormat.format(c.getTimeInMillis());
    }
Run Code Online (Sandbox Code Playgroud)

我的模型CommentEntity具有以下属性:

 private int id;
 private int productId;
 private String text;
 private Date postedAt;
Run Code Online (Sandbox Code Playgroud)

现在,在布局之一中,我将显示注释。

<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto">
    <data>
        <variable name="comment"
                  type="com.example.entity.CommentEntity"/>
        <variable
        name="dateUtil"
        type="com.example.util.DateUtil"/>

    </data>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_margin="8dp"
                android:layout_alignParentRight="true"
                android:layout_below="@id/item_comment_text"

                //This line gives error for data binding
                android:text="@{dateUtil.formatDate(comment.postedAt.time)}"/>
</layout>
Run Code Online (Sandbox Code Playgroud)

我得到的错误是:

在类long中找不到方法formatDate(com.example.util.DateUtil)

现在,对于相同的情况,如果我修改formatDate()方法,因为默认情况下它将花费当前时间,因此删除了数据绑定中传递的参数,它将可以完美地工作。

那么我是在做错什么还是错误?

请提供在数据绑定中将参数传递给方法的问题的解决方案。

android android-databinding

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