了解Android的R类 [英] Understand the R class in Android

查看:167
本文介绍了了解Android的R类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android的,我不知道我很理解研究类。我经历了数独例子,我有这样的snipet的code:

In android, I'm not sure I quite understand the R class. I'm going through the sudoku example, and I have this snipet of code:

switch (v.getId()) // the id of the argument passed is is evaluated by switch statement
{
    case R.id.about_button: // 
    Intent i = new Intent(this, about.class);
    startActivity(i);
    break;
    // More buttons go here (if any) ...
}

我是全新到Java,但是从我收集它看起来像它采取输入(触摸屏被触摸按钮),并计价的说法。那么case语句是设置如果有关按钮被识别,并创建一个新的界面屏幕,然后导航到手机上。

I'm brand new to Java, but from what I gather it looks like it's taking input (the touch screen being touched on the button) and valuating the argument. Then the case statement is setup if the about button is recognized, and a new interface screen is created and then navigated to on the phone.

这是正确的?

如果我得到了正确的JIST,为什么处理的R级?

If I got the jist of that correct, why is the deal with the "R" class?

为什么叫识别按钮的ID?

Why is it called to recognize the ID of the button?

我觉得超级类(在此项目)是SudokuActivity类。

I thought the super class (in this project) was the SudokuActivity class.

推荐答案

R.java 是动态生成的类,在构建过程中创建的动态识别所有资产(从串到Android窗口小部件布局),用于在使用中的Java类Android应用程序。请注意,此 R.java 的是Android特有的(虽然你可能能够复制它的其他平台,它非常方便),所以它不会有很多工作要做与Java语言结构。看看<一href="http://knowledgefolders.com/akc/display?url=displaynoteimpurl&ownerUserId=satya&reportId=2883"相对=nofollow>此处,了解更多信息。

R.java is the dynamically generated class, created during build process to dynamically identify all assets (from strings to android widgets to layouts), for usage in java classes in Android app. Note this R.java is Android specific (though you may be able to duplicate it for other platforms, its very convenient), so it doesn't have much to do with Java language constructs. Take a look here, for more details.

这篇关于了解Android的R类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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