0

此代码不起作用。我检查了displayLanguage值。值是正确的(displayLanguage="Türkçe")。但它不起作用。

private void setAdvertisement()
{

Locale _locale = Locale.getDefault();
String displayLanguage = _locale.getDisplayLanguage();
if(displayLanguage == "Türkçe")
{
    // Create the adView
    adView = new AdView(this, AdSize.BANNER, "My Admob ID");

    // Lookup your LinearLayout assuming it’s been given
    // the attribute android:id="@+id/mainLayout"


    // Add the adView to it
    linearLayoutAdvertisement.addView(adView);

    // Initiate a generic request to load it with an ad
    adView.loadAd(new AdRequest());
}
}

但是这段代码工作正常:

private void setAdvertisement()
{
        // Create the adView
        adView = new AdView(this, AdSize.BANNER, "My Admob ID");

        // Lookup your LinearLayout assuming it’s been given
        // the attribute android:id="@+id/mainLayout"


        // Add the adView to it
        linearLayoutAdvertisement.addView(adView);

        // Initiate a generic request to load it with an ad
        adView.loadAd(new AdRequest());

}

我不明白问题是什么。

4

2 回答 2

1

这不是 AdMob 问题。但是试试这个:

if ("Türkçe".equals(displayLanguage)) {
  ..
}
于 2012-07-11T17:43:29.977 回答
0

我解决了问题。这对我有用:

if(Locale.getDefault().getLanguage().equals("tr"))
    {
        ...
    }
于 2012-07-12T15:17:15.570 回答