改变开关至"如果其他"声明

问题描述:

我刚刚成为对编程感兴趣,我想创建手机或平板电脑的Andr​​oid应用程序。我从知道几乎没有什么关于Java / XML走过了很长的路在几个星期。我很认真的。我要找到这个问题的答案的一种方式或其他。事实上,我希望能有它想通了,才有人回答了这个。我已经修正了许多问题,而不是诉诸问任何人,但我刚刚一直停留在这个问题上太长时间。我想我应该给这个一杆。

I've just recently become interested in programming, and I want to create Android apps for phones or tablets. I've come a long way in a couple weeks from knowing almost nothing about java/xml. I'm very serious about this. I'm going to find the answer to this question one way or the other. In fact, I hope to have it figured out before anyone answers this. I've fixed many issues without resorting to asking anyone, but I've just been stuck on this issue too long. I figured I'd give this a shot.

我使用的是较旧的教程构建一个实践Twitter的应用程序(该教程这些似乎无处不在,这就是为什么我选择了它)。我使用的Eclipse的编辑器。

I'm using an older tutorial to build a practice twitter app (the tutorials for these seem to be everywhere, which is why I chose it). I'm using Eclipse for an editor.

下面是本教程code的例子。其中涉及到我的问题:

The following is an example of code from the tutorial. which relates to my question:

@Override
    public void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.timeline);

显然,因为ADT 14的介绍,你可以不再使用(R.layout.timeline)的短语,该错误信息是指为switch语句。

Apparently since the intro of ADT 14, you can no longer use the (R.layout.timeline) phrase, which the error message refers to as a "switch statement."

现在,在后我发现另一个网站,别人谁也有类似的问题,给出了使用CTRL + 1速战速决在Eclipse中的截图。在截图,弹出的修正:转换开关的if-else语句。此修复程序不弹出我的版本的Eclipse。我快速修复选项迁移的Andr​​oid code,类型创建领域'时间表'布局',类型创建常量'时间表'布局'或重命名文件。

Now, in a post I found on another site, someone who had a similar issue shows a screenshot of the "quick fix" in Eclipse using ctrl+1. in the screenshot, the fix that pops up says "convert switch to 'if-else' statement." This fix does not pop up in my version of Eclipse. My quick fix options are "migrate Android code", "create field 'timeline' in type 'layout'", "create constant 'timeline' in type 'layout'" or "rename in file."

如果我选择迁移的Andr​​oid code,会弹出一个窗口,通知ADT 14日更新的我,怎么switch语句在库项目不再允许。它说,switch语句转换为的if-else语句由pressing Ctrl + 1快速修复,然后选择转换到的if-else'语句就像它在我找到了截图。但同样,当我这样做,该选项不会弹出。

If I choose "migrate Android code", a window pops up informing me of the ADT 14 update, and how switch statements are no longer allowed in library projects. It says to convert the switch statement to an "if-else" statement by pressing ctrl+1 for the quick fix, then choosing "switch to 'if-else' statement" like it does in the screenshot I found. But again, when I do this, that option does not pop up.

我宁愿知道需要在code比知道如何做出正确的速战速决弹出要改变什么。如果不是太麻烦了,为什么正是这些变化是情感的解释将是非常有益的。我在我的java文件有很多(很多)错误的权利,但他们大多是由于不同形式的这一确切的问题。如果我能看到的只是一前/后例子我大概可以算出它从那里没有一个解释。但搜索了几个小时之后,我找不到,到目前为止,通过谷歌搜索。

I would much rather know what needs to be changed in the code than know how to make the right quick fix pop up. If it isn't too much trouble, an explanation of why exactly these changes are affective would be very helpful. I have many (MANY) errors in my java files right now, but most of them are due to this exact problem in different forms. If I could see just one before/after example I could probably figure it out from there without an explanation. But after hours of searching, I cannot find that so far by googling.

在此先感谢这么多......

Thanks so much in advance....

和备案,我没有看到任何开关类我的任何java文件,如果有差别的答案...

And for the record, I don't see any switch classes in any of my java files, if that makes a difference for the answer...

请确保你的开关点击关键字本身则preSS 控制大骨节病> + 1 骨节病>。
这个困惑我在第一,以及...

Make sure you click on the switch keyword itself then press Ctrl + 1.
This confused me at first as well...

如果它仍然没有出现,你使用的是什么版本的Eclipse?

If it still doesn't show up, what version of Eclipse are you using?

如果您使用的是Mac选择关键字开关,点击移骨节病> + 命令骨节病> + 1 骨节病>。
这将显示一个提示,更改开关的if else 的条件。

If you are using a Mac select the keyword switch and click Shift + Command + 1.
That will show a prompt to change switch to if else conditions.