从其他语言获取“en”的国家/地区

时间:2016-03-30 11:18:07

标签: android location autocompletetextview google-translate

我的AutoCompleteTextView工作正常,但我需要以用户的语言返回响应,为此我使用:

Locale.getDefault().getLanguage()

问题是当我需要用英语(en)向后端发送响应时。

例如:

我收到下一个位置:“巴塞罗那,西班牙”

我需要发送到后端:“西班牙巴塞罗那”

这是我的AutocompleteTextView

private void initilizeAutoCompleteTextView() {

    CustomFontHelper.setCustomFont(mAutoCompleteTextViewLocation, CustomFontHelper.FONT_BOLD, getActivity().getApplicationContext());
    PlacesAutoCompleteAdapter placesAdapter = new PlacesAutoCompleteAdapter(getActivity().getApplicationContext());
    mAutoCompleteTextViewLocation.setAdapter(placesAdapter);

    mAutoCompleteTextViewLocation.setHint(mUser.getCountry());

    mAutoCompleteTextViewLocation.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            onLocationItemClick(parent, view, position, id);

            ViewHelper.hideKeyboard(getActivity());
        }
    });

}

void onLocationItemClick(AdapterView<?> parent, View view, int position, long id) {
    String description = (String) parent.getItemAtPosition(position);
    Toast.makeText(view.getContext(), description, Toast.LENGTH_SHORT).show();
    mAutoCompleteTextViewLocation.setTag(description);

    doCallback(mAutoCompleteTextViewLocation.getTag().toString());

}

如果有人知道解决方案,我将非常感激。

0 个答案:

没有答案