代码片段正在Eclipse中出现,为什么? [英] Code fragments are being struck out in Eclipse, why?

查看:126
本文介绍了代码片段正在Eclipse中出现,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我制作Android应用程序时,Eclipse会发现一些事情。更具体地说, Gallery 。这是一个屏幕截图:





当我将鼠标悬停在警告上时,它表示不推荐使用图库类型。我不知道什么是 deprecated 的意思,但我知道这是一个Java术语。任何帮助将不胜感激。谢谢!

解决方案

(从编辑前的问题:该术语已被弃用,不折旧,这是一个常见的错字,但值得意识到搜索目的:)



它基本上有点像过时 - 鼓励不要使用不推荐使用的类或方法。通常,文档将解释为什么您不想使用它们,并为您提供更好的选择。通常情况下,已弃用的版本仅适用于向后兼容性。



如果您使用的是不推荐使用的API,那么值得这么认真考虑 - 很多时候来自一个从根本上有缺陷的方法的东西。 日期 是最清楚的例子,其中Java 1.0 API几乎完全在1.1中被弃用,当 日历 被介绍。在 Date 中使用不推荐使用的方法是为您自己存储问题的一种可行方法。



请参阅Oracle 如何以及何时弃用API页面了解更多信息。 / p>

While I'm making an Android app, Eclipse will strike out some things. More specifically, Gallery. Here is a screen shot:

When I hover my mouse over the warnings, it says The type Gallery is deprecated. I don't know what Deprecated means, but I do know that it's a Java term. Any help would be appreciated. Thanks!

解决方案

(From the question before editing: The term is deprecated, not depreciated. It's a common typo, but worth being aware of for searching purposes :)

It's basically a bit like "obsolete" - you're encouraged not to use classes or methods which are deprecated. Typically the documentation will explain why you're not meant to use them, and give you a better alternative. The deprecated version is only present for backward compatibility, usually.

It's worth taking this seriously - a lot of the time if you're using a deprecated API, you're coming at something from a fundamentally flawed approach. Date is the clearest example of this, where the Java 1.0 API was almost entirely deprecated in 1.1, when Calendar was introduced. Using the deprecated methods in Date is a sure way of storing up problems for yourself.

See the Oracle "How and when to deprecate APIs" page for more information.

这篇关于代码片段正在Eclipse中出现,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆