什么是"点"注册一个活动时,对QUOT

2023-09-12 09:00:59 作者:全幼儿园最帅

我是怎样的一个小白在编程为Android操作系统。我注意到,在书我一直在读的注册他们的活动清单时,作者都放置了一个点的活动名称的前面。我环视了一下Android开发者网站,我能不明白,为什么我们需要的点。请问点,实际上服务器的目的?我需要它?我已经包括下面的一个例子。请注意NewActivity前的点:

 <活动机器人:名称=。NewActivity>< /活性GT;
 

解决方案

正如您已经注意到的一点是没有必要的,但它的基本含义:活动类生活在同一个包中的应用程序的。所以,如果您的应用程序包为: com.my.package 则:

.YourActivity 意味着你的类里面 com.my.package YourActivity 意味着你的类里面 com.my.package (同​​上)。 .activities.YourActivity 意味着你的类里面 com.my.package.activitites 。 您甚至可以这样做: com.my.package.activities.YourActivity 当你想要有不同的版本,您的应用程序,并使用Ant来改变这是有用自动给包的参考文献。

I'm kind of a noob at programming for the Android OS. I noticed in the books I have been reading that the authors have placed a "dot" in front of the activity name when registering their activities in the manifest. I've looked around the Android developer site and I can't figure out why we need the "dot". Does the "dot" actually server a purpose? Do I need it? I have included an example below. Notice the "dot" before "NewActivity":

<activity android:name=".NewActivity"></activity>
CF手游体验服如何注册邮箱 体验服邮箱

解决方案

As you have noticed the point is not necessary but it basically means: the activity class lives in the same package of the app. So, if your app package is: com.my.package then:

.YourActivity means that your class is inside com.my.package. YourActivity means that your class is inside com.my.package (same as above). .activities.YourActivity means that your class is inside com.my.package.activitites. You can even do something like: com.my.package.activities.YourActivity which is useful when you want to have different versions of your app and use Ant to change the references to the package automatically.