gpt4 book ai didi

More activities or 1-2 activities and multiple fragments? Jetpack compose or XML or both? [closed](更多的活动还是1-2个活动和多个片段?Jetpack Compose还是XML,还是两者兼而有之?[已关闭])

转载 作者:bug小助手 更新时间:2023-10-25 10:06:17 25 4
gpt4 key购买 nike




I'm building a simple app that's basically text input and multiple-choice input from a recycler view, pulled from an api. Then exporting the form answers to a pdf, uploading that to a database and accessing the database.

我正在构建一个简单的应用程序,基本上是文本输入和从回收器视图中的多项选择输入,从API中拉出。然后将表格答案导出为pdf,将其上传到数据库并访问数据库。


That being said, I've only worked with XML and with multiple activities but not with fragments. So, my questions re:
Is there a rule of thumb for when to use activity vs when to use a fragment?
Should I continue with XML since I'm doing basic things here or is it worth learning jetpack compose since I am on a deadline?

也就是说,我只使用过XML和多个活动,而没有使用片段。那么,我的问题是:什么时候使用活动,什么时候使用片段,有没有一个经验法则?既然我在这里做一些基本的事情,我应该继续使用XML吗?或者因为我的截止日期已经到了,所以是否值得学习Jetpack编写?


更多回答

First off, you're asking several unrelated questions here. Secondly, each of them is an opinion question, which is off topic here. There's ways to ask about the pros and cons of say activities vs fragments (which btw aren't the only two options), but the way you're asking is far too vague.

首先,您在这里问了几个不相关的问题。其次,它们每一个都是一个观点问题,这在这里是离题的。有很多方法可以询问活动和片段的优缺点(顺便说一句,这并不是唯一的两个选项),但你询问的方式太模糊了。

优秀答案推荐


Is there a rule of thumb for when to use activity vs when to use a fragment?



The fragments were created to make supporting different screen sizes easier, so if you are planning on making apps that do support all screen sizes, you would use fragments

创建这些片段是为了更容易地支持不同的屏幕大小,所以如果你计划开发支持所有屏幕大小的应用程序,你可以使用片段


Example: gmail on a phone and a tablet:

例如:手机和平板电脑上的Gmail:


enter image description hereenter image description here


As you see on the tablet there are more componenets visible, which were (probably) created with fragments

正如你在平板上看到的,有更多的成分可见,它们(可能)是用碎片创建的



Should I continue with XML since I'm doing basic things here or is it worth learning jetpack compose since I am on a deadline?



As a person that had to switch to compose due to work related reasons, I would recommend sticking to XML, making a smooth working app with low experience in compose will be a bit tricky (it took me more than a month to get used to compose)

作为一个因为工作原因不得不改用作曲的人,我会建议坚持使用XML,做一个流畅的、没有作曲经验的工作应用程序会有点棘手(我花了一个多月的时间才习惯作曲)


更多回答

Also it has become a bit of a community-standard to use one activity, multiple fragments approach in your android apps, but that doesn't really matter

此外,在你的Android应用程序中使用一种活动、多个片段的方法也有点像社区标准,但这并不重要

It's a common way of doing things, but far from universal. Lots of apps still use activities. Lots of apps also choose neither of those, since fragments are pretty universally considered clunky in large apps (try putting a fragment in a recycler view and you'll see why the fragment API is pretty horrible).

这是一种常见的做事方式,但远不是普遍的。许多应用程序仍在使用活动。许多应用程序也不选择这两个,因为在大型应用程序中,碎片被普遍认为是笨重的(尝试将碎片放在回收器视图中,你就会明白为什么碎片API相当可怕)。

"Lots of apps still use activities." mostly applications created in the past I think, also that example is.... not the best (with all due respects), why would one want to create a fragment for each item in recycler view?

“很多应用程序仍在使用活动。”我认为大多数应用程序都是在过去创建的,这个例子也是……不是最好的(恕我直言),为什么要在回收器视图中为每个项目创建一个片段?

No, lots of new applications do too. Most places I've worked over the last decade have banned fragments because the API for them is too problematic. They use the same type of idea of reusable UI pieces, but they roll their own. And as for the recyclerview- a fragment is a set of UI and functionality that you want to reuse in multiple places. One of those can easily be a recycler view. In fact it's one of the most common ones. The inability to do so is one of the reasons why Fragments are considered a failed idea.

不,许多新的应用程序也是如此。在过去的十年里,我工作过的大多数地方都禁止碎片,因为它们的API太有问题了。他们使用相同类型的可重用UI组件的想法,但他们自己滚动。至于回收器视图--片段是一组你想在多个地方重复使用的用户界面和功能。其中之一很容易成为回收者的观点。事实上,这是最常见的一种。无法做到这一点是碎片被认为是一个失败的想法的原因之一。

Good to learn something new, I am but a junior dev :D

很高兴学到新东西,我只是个初级开发人员。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com