简体   繁体   English

在 Android 中使用 GridView 安全吗?

[英]Is it safe to use GridView in Android?

So I know GridView is deprecated, but is it okay to use GridView for production code?所以我知道 GridView 已被弃用,但是可以将 GridView 用于生产代码吗?

I would like to use it for my game app.我想将它用于我的游戏应用程序。

The Android Studio client says it has been deprecated in favor of ConstraintLayout, but trying to set up a grid (which should be a very simple, straightforward task) is such a hassle using ConstraintLayout. Android Studio 客户端表示它已被弃用而支持 ConstraintLayout,但是尝试设置网格(这应该是一项非常简单、直接的任务)使用 ConstraintLayout 非常麻烦。

So I know GridView is depreciated所以我知道 GridView 折旧了

GridView is not deprecated, according tothe JavaDocs根据JavaDocsGridView没有被弃用

The Android Studio client says it has been depreciated in favor of ConstraintLayout Android Studio 客户端说它已被折旧以支持 ConstraintLayout

GridView and ConstraintLayout are not equivalent things, so that recommendation does not make sense. GridViewConstraintLayout不是等价的东西,所以推荐没有意义。

GridLayout is comparable to ConstraintLayout . GridLayoutConstraintLayout相当。 GridLayout is also not deprecated . GridLayout没有被弃用

but is it okay to use GridView for production code?但是可以将 GridView 用于生产代码吗?

Both GridView and GridLayout are safe for use in production code. GridViewGridLayout在生产代码中使用都是安全的。 They are obsolete, and I would not recommend that anyone use them, but they are safe.它们已经过时,我不建议任何人使用它们,但它们是安全的。

  • If what you want is a scrollable container of items in a grid, you can use GridView , though RecyclerView and GridLayoutManager would be a better choice如果您想要的是网格中项目的可滚动容器,您可以使用GridView ,尽管RecyclerViewGridLayoutManager将是更好的选择

  • If what you want is a non-scrollable container of items in a grid, you can use GridLayout or perhaps TableLayout , though ConstraintLayout would be a better choice如果您想要的是网格中不可滚动的项目容器,则可以使用GridLayoutTableLayout ,尽管ConstraintLayout将是更好的选择

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM