如何在alertDialog上委派所选项目并进行翻译

时间:2015-07-28 13:33:44

标签: java android string

我不明白如何使用array.xml翻译alertDialog中的字符串并委托所选项目。

我有这个代码来显示我的alertdialog:

final CharSequence[] items = {
                        "Spam",
                        "Nudez ou pornografia",
                        "Violência explícita",
                        "Ataque a um grupo ou indivíduo",
                        "Outro"
                };

                final String REASON_SPAM = "REASON_SPAM";
                final String REASON_NUDITY = "REASON_NUDITY";
                final String REASON_VIOLENCE = "REASON_VIOLENCE";
                final String REASON_BULLYING = "REASON_BULLYING";
                final String REASON_OTHERS = "REASON_OTHERS";

                AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
                builder.setTitle("Motivo");
                builder.setItems(items, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int item) {
                        String reason = REASON_OTHERS;
                        if (items[item].equals("Spam")) {
                            reason = REASON_SPAM;
                        } else if (items[item].equals("Nudez ou pornografia")) {
                            reason = REASON_NUDITY;
                        } else if (items[item].equals("Violência explícita")) {
                            reason = REASON_VIOLENCE;
                        } else if (items[item].equals("Ataque a um grupo ou indivíduo")) {
                            reason = REASON_BULLYING;
                        } else {
                            reason = REASON_OTHERS;
                        }

                        ProfileTask.reportUser(ctx, userEntity.apiId, reason);
                    }
                }).show();
            }

我需要翻译字符串:|

0 个答案:

没有答案