意向构造函数的语法 [英] Intent constructor syntax
问题描述
我刚开始开发Android(是一个.NET开发人员)
I am just starting to develop Android (being a .Net developer)
我下面从一本书code,并开始一个新的形式(屏幕),它显示了code
I am following the code from a book, and to start a new 'form' (screen) they show this code
Intent i = new Intent("net.learn2develop.ACTIVITY2");
类定义是这样的:
The class definition is this:
package net.learn2develop.Activities;
//imports removed
public class Activity2 extends Activity {
我的问题是:我presume是在意图构造函数的字符串是类名。
但为什么'net.learn2develop
,而不是'net.learn2develop.Activities
为什么是所有类名帽?
My question is: i presume that the string in the constructor in the Intent is the classname.
But why is it 'net.learn2develop'
and not 'net.learn2develop.Activities'
and why is the classname all caps?
推荐答案
看看文档:<一href=\"http://developer.android.com/reference/android/content/Intent.html#Intent%28java.lang.String%29\">Intent(String动作)。
所以,这其实是动作的名称,而不是类名。他们通常看起来非常相似,未prepared眼球。看看的AndroidManifest.xml
并搜索 net.learn2develop.ACTIVITY2
字符串。你应该找到像服用点:
So this is actually action name, not class name. They usually look very similar to unprepared eye. Take a look at AndroidManifest.xml
and search for net.learn2develop.ACTIVITY2
string. You should find somehting like:
<activity android:name=".Activity2" >
<intent-filter >
<action android:name="android.intent.action.ACTIVITY2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
这篇关于意向构造函数的语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!