什么是"点"注册一个活动时,对 [英] What's the "dot" for when registering an Activity

查看:80
本文介绍了什么是"点"注册一个活动时,对的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是怎样的一个小白在编程为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>

解决方案

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.

这篇关于什么是&QUOT;点&QUOT;注册一个活动时,对的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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