Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] xml – Issue with android application localizing

Posted on November 14, 2022

Solution 1 :

Going through different releated posts, I found something similar here in this post and tried something similar. Reloading the localization settings after setContentView(webview_layout) worked. There is some bug/issue in the WebView in android OS that resets all the localization settings and put it back to default settings once the layout is loaded.

Problem :

I’m trying to localize my app in android studio. All works great unless I open this one specific activity and everything starts going crazy. My app supports English and Arabic language.
All strings are available in both resources sets(strings-en.xml and strings-ar.xml) English is the base language in app.

I have 8-10 different activities and fragments. I can open all activities and fragments and everything is localized BUT there is only one activity where everything messes up and after that activity all screens starts showing default localization(en). In this one activity I’ve a webview and some IntentExtras to deal with and read the urls and title of the activity. Even the default URL and Title that i’ve defined in the strings.xml is not localized.

Any help is appreciated.

This is a code snippet from WebviewActivity, I’m simply doing startActivity from previous and setting “target” and “url” in IntentExtras.

    String title = getText(R.string.BrandName).toString();
    target = getIntent().getIntExtra("target", 0);

    switch (target){
        case 1:
            title = getText(R.string.terms).toString();
            Url = getText(R.string.terms_url).toString();
            break;
        default:
            title = getText(R.string.default).toString();
            Url = getText(R.string.default_url).toString();
            break;
     }
    getSupportActionBar().setTitle(title);

webview_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns_android="http://schemas.android.com/apk/res/android"
android_layout_width="match_parent"
android_layout_height="match_parent"
android_background="@color/offwhite">
<include layout="@layout/app_bar_layout" />
<LinearLayout
    android_layout_width="match_parent"
    android_layout_height="wrap_content"
    android_orientation="vertical"
    android_visibility="gone"
    android_layout_centerInParent="true"
    android_id="@+id/noInternetLayout"
    android_layout_margin="@dimen/dimen_10">
    <ImageView
        android_layout_width="100dp"
        android_layout_height="100dp"
        android_layout_gravity="center"
        android_tint="@color/grey"
        android_src="@drawable/ic_nonet"
        android_layout_margin="@dimen/dimen_4"/>
    <TextView
        android_layout_width="match_parent"
        android_layout_height="match_parent"
        android_layout_margin="@dimen/dimen_4"
        android_textAlignment="center"
        android_text="@string/noInternetConnection"
        android_textStyle="bold|italic" />
</LinearLayout>

<WebView
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_id="@+id/webView"
    android_layout_below="@+id/appbar"
    android_visibility="gone"/>
<ProgressBar
    android_id="@+id/progressBar"
    android_progressTint="@color/grey"
    android_layout_width="wrap_content"
    android_layout_height="wrap_content"
    android_layout_centerHorizontal="true"
    android_layout_centerVertical="true"
    android_layout_centerInParent="true"
    />

</RelativeLayout>

Comments

Comment posted by Lena Bru

please share the code of how you display the webview

READ  [ANSWERED] android - Goole Play Application update - Keep Getting SSL Error Handler
Powered by Inline Related Posts

Comment posted by Joe

I was just trying different things and found out that if i put

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress