问题标签 [android-components]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
9 回答
18090 浏览

android - Room 不能选择一个构造函数,因为多个构造函数是合适的错误

我尝试在我的 android kotlin 项目中实现持久库,但在编译时发现此错误:

错误:房间不能选择一个构造函数,因为多个构造函数是合适的。尝试使用 @Ignore 注释不需要的构造函数。

错误代码:

0 投票
1 回答
1135 浏览

android - 如何使用 Room Peristence Library 中的 Relation 注释保存 POJO?

我目前正在玩 Room 以便将其与 Realm 进行比较,并且我已经对最好的做事方式有很多疑问。

在我的示例应用程序中,我有一个非常简单的模型,其中一个 aPerson可以有Cats 和Dogs。

这里是java类。

CatDog类从一个类继承Animal

Cat班级:

Dog班级:

Person班级:

我还有一个 POJO 来模拟用户可以养猫和狗的事实:

问题是:如何保存RoomPersonWithAnimals对象列表?

我不能Insert在类中使用注释,Dao因为RoomPersonWithAnimals它不是Entity.

对于我列表中的每个对象,我RoomPersonWithAnimals应该运行 3 个请求吗?

  • 一是为了插入person属性;
  • 一个以插入列表cats
  • 一个以插入列表dogs

预先感谢您的帮助 !

0 投票
4 回答
14762 浏览

android - kotlin android 启动新服务

通过使用下面的代码,我正在尝试从 a 启动新服务Broadcast receiver,但该服务似乎没有启动。在kotlin启动服务的正确方法是什么?

0 投票
9 回答
81730 浏览

android - Android ViewModel 附加参数

有没有办法将附加参数传递给我的自定义AndroidViewModel构造函数,除了应用程序上下文。例子:

当我想使用我的自定义ViewModel类时,我在我的片段中使用此代码:

所以我不知道如何将额外的参数传递String param给我的 custom ViewModel。我只能传递应用程序上下文,但不能传递其他参数。我真的很感激任何帮助。谢谢你。

编辑:我添加了一些代码。我希望现在好多了。

0 投票
0 回答
266 浏览

android - android mvvm room 数据库深层结构

我是 android 的初学者。我正在尝试使用新的 android MVVM 架构开发一个应用程序。参考下面GitHub的google示例代码:

https://github.com/googlesamples/android-architecture-components/tree/master/GithubBrowserSample

我正在使用 Room、Data Binding、Retrofit、Dagger 2

我开发的列表活动适用于上述架构

我的 API 电影列表响应:

但我面临细节活动的问题我的电影细节 API 响应是:

在我的应用程序中,我有 2 个实体 1.MovieEntity 2.MovieSourceEntity

按照我的存储库代码:

此代码仅返回 MovieEntity 数据 loadFromDb 不返回 MovieSourceEntity ListOfData 任何人都知道如何实现这一点

回答

0 投票
1 回答
636 浏览

android - SQL delete where NOT IN 不起作用

我正在使用 Android 组件中的 room dao。我需要的是:插入列表,但之前 - 从 db 中删除所有数据,其 id 与新列表中的 id 不同。

这是我的简单数据类:

我的任务的最佳选择是使用DELETE WHERE NOT IN someArray. 这是我的代码中的示例:

因此,当我收到必须保存的新列表时,我会使用 ids: 创建下一个 String"'0','1'"并调用 method deleteUniqueData

但是每次我调用它时,我都会收到2结果,这意味着有 2 行被删除。

有趣的部分:当我更换

我收到0结果。所以看起来Room有问题。

任何想法为什么NOT IN不起作用?或者如何修复?

更新

这是生成的查询:

0 投票
1 回答
393 浏览

android - 无法从房间中移除实体

我有LoggedInUserEntityUserRecentSearch最后一个在哪里有 foreignKeys LoggedInUserEntity。当我想删除LoggedInUserEntity时,如果数据库中只有 no 是可能UserRecentSearch的。

我该如何删除?

我如何使用关系?

我如何删除LoggedInUserEntity现有的UserRecentSearch

0 投票
2 回答
1754 浏览

android - Material Design Components Site

Today I was Googling for "material design components" I ended up at this site:

https://material.io/components/

As I remember, I've never seen it before.

In the Android section there are instruction to use the components and ok, it seems to be the well-known Android Design Support Library:

Screenshot of dependencies

But what intrigues me is that there are components there that are not in the design library, such as:

Back Layer Layout, Material Card and Material Button.

The docs for these classes seems to be not ready yet and the links points to nowhere, like: material button doc.

There is something in the github site.

Sorry for ignorance, but what is the purpose of this site? Is it something future or something left behind?

0 投票
0 回答
270 浏览

android - 无法启动自定义组件“AppCompatEditText”类

我正在尝试创建我创建的自定义 AppCompactEditText。我还创建了一个示例应用程序来测试我的自定义组件。但是,当我从示例应用程序的 xml 调用/输入我的自定义编辑文本时,它崩溃并给出错误java.lang.RuntimeException: Unable to start activity ComponentInfo

这是我的代码

我在这样的示例应用程序中调用它

这是我得到的错误

我也以正确的方式导入了自定义组件/模块。有人可以帮我弄清楚我做错了什么。提前致谢。

0 投票
1 回答
8300 浏览

android - 使用 android room 持久性库在对象内插入对象

目录

图像模型

目录道

如何在目录中插入图像列表?我应该为图像创建一个单独的道吗?