【问题标题】:Custom title for AccountPickerAccountPicker 的自定义标题
【发布时间】:2016-04-15 22:22:35
【问题描述】:

来自AccountPickernewChooseAccountIntent() 方法允许您通过descriptionOverrideText 参数自定义AccountPicker“对话框”(实际上是Activity)中的文本:

public static Intent newChooseAccountIntent (Account selectedAccount, ArrayList<Account> allowableAccounts, String[] allowableAccountTypes, boolean alwaysPromptForAccount, String descriptionOverrideText, String addAccountAuthTokenType, String[] addAccountRequiredFeatures, Bundle addAccountOptions)

但“对话框”还带有一个默认设置为“选择帐户”的标题,例如 this post 中包含的屏幕截图。

如何自定义此标题,甚至完全删除它?重点不是我想更改措辞,而是我希望能够将措辞翻译成其他语言……对于我的应用程序的用户来说,目前的用户界面不是很好,其他所有内容都使用当地语言,但不是这个“对话”的标题。

【问题讨论】:

  • 由于这是 Google 专有的 API,因此无法更改所述对话框的文本。您可以通过更改系统本身的语言来检查标题本身是否使用i18n

标签: android google-play-services accountpicker


【解决方案1】:

我知道问这个问题已经快 5 年了,但最近我遇到了同样的问题,很难找到帮助。最后,我已经解决了。您不能删除或自定义标题。可以做的是在标题下方添加一个描述为String descriptionOverrideText,像这样:

public static Intent newChooseAccountIntent (null, null, new String[]{"com.google"}, false, "HERE ADD SOME TEXT", null, null, null)

【讨论】:

  • 谢谢,但最初的问题已经提到了传递descriptionOverrideText的值的可能性...新年快乐!
【解决方案2】:

对于 AccountPicker,请使用以下代码更改标题:

AccountPicker.newChooseAccountIntent(
            AccountPicker.AccountChooserOptions.Builder()
                    .setAllowableAccountsTypes(Arrays.asList("com.google"))
                    .setTitleOverrideText("change the title here")
                    .build())

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-09
    • 2013-09-02
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多