如何获得最爱的星星

发布于 2024-09-13 18:25:29 字数 450 浏览 2 评论 0原文

我想添加一个最喜欢的星星,就像 Android 上联系人列表中的星星一样。我们有什么办法可以获得那颗星吗?还是我必须自己写?除了选项菜单图标之外,我似乎找不到任何来自 android 的标准 GUI 元素。还有其他我没找到的吗?

看看乔治·安德森旁边的那个。当你点击它时,它会变成黄色。

替代文本
(来源:mail2web.com

I would like to add a favorites star like the one in the contacts list on android. Is there any way we can get that star or will I have to write my own? I can't seem to find any standard GUI Elements from android other than the options menu icons. Are there any more that I have not found?

Look at the one the right next to George Anderson. When you click it it turns yellow.

alt text
(source: mail2web.com)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

慢慢从新开始 2024-09-20 18:25:29

联系人应用程序的源代码可在线获取,因为 Android 是开源的。

在那里进行一些探索将引导您找到 contact_header.xml 文件,该文件可在您的 SDK 安装中找到。它表明星号是通过 CheckBox 实现的:

<CheckBox
        android:id="@+id/star"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:visibility="gone"
        android:contentDescription="@string/description_star"
        style="?android:attr/starStyle" />

反过来,它会将您路由到主题中的一个条目:

<item name="starStyle">@android:style/Widget.CompoundButton.Star</item>

该条目又解析为:

<style name="Widget.CompoundButton.Star">
    <item name="android:background">@android:drawable/btn_star_label_background</item>
    <item name="android:button">@android:drawable/btn_star</item>
</style>

因此,将这些图像与 CheckBox< 一起使用/code>,你应该得到相同的行为。这些图像也可以在您的 SDK 安装中找到。

The source code to the Contacts application is available online, since Android is open source.

Some poking around in there will lead you to the contact_header.xml file, found in your SDK installation. It indicates that the star is implemented via a CheckBox:

<CheckBox
        android:id="@+id/star"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:visibility="gone"
        android:contentDescription="@string/description_star"
        style="?android:attr/starStyle" />

That, in turn, routes you to an entry in a theme:

<item name="starStyle">@android:style/Widget.CompoundButton.Star</item>

which in turn resolves to:

<style name="Widget.CompoundButton.Star">
    <item name="android:background">@android:drawable/btn_star_label_background</item>
    <item name="android:button">@android:drawable/btn_star</item>
</style>

So, use those images with a CheckBox, and you should get the same behavior. Those images are also available in your SDK installation.

少女的英雄梦 2024-09-20 18:25:29

android sdk 提供了一些标准的 android 镜像,您可以在计算机上在线浏览这些镜像 此处。 (正如 CommonsWare 所说)。

我还发现 这个网站 非常方便,因为它向我展示了每个图像的外观并告诉我该图像的名称图像,以便我可以在 android sdk 中找到它。

Some standard android images are available from the android sdk, which you can either browse on your computer on online here. (As CommonsWare said).

I also find this website super handy, as it shows me what each image looks like and tells me the name of the image so I can find it in the android sdk.

埖埖迣鎅 2024-09-20 18:25:29

@android:drawable/btn_star (这个变成黄色)

@android:drawable/star_off

以及它们的变体(大、开、关)

@android:drawable/btn_star (this one turns yellow)

@android:drawable/star_off

and variations on those (big, on, off)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文