简体   繁体   English

我想从字符串中写入 AdUnitId?

[英]I want to write the AdUnitId from String?

I want to write the AdUnitId from String我想从字符串中写入AdUnitId

  MobileAds.initialize(this, new OnInitializationCompleteListener() {
            @Override
            public void onInitializationComplete(InitializationStatus initializationStatus) {
            }
        });
        AdView adView = new AdView(this);
        adView.setAdSize(AdSize.BANNER);
        adView.setAdUnitId("ca-app-pub-8580705205581022/6543518491");
        mAdView = findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);

you can go into your strings.xml in the values directory and add <string name="app_unit_id" translatable="false">ca-app-pub-8580705205581022/6543518491</string> and in your code you just write adView.setAdUnitId(getString(R.string.app_unity_id));您可以进入 values 目录中的 strings.xml 并添加<string name="app_unit_id" translatable="false">ca-app-pub-8580705205581022/6543518491</string>并在您的代码中编写adView.setAdUnitId(getString(R.string.app_unity_id));

You dont need the translateable="false" if you dont use localization如果您不使用本地化,则不需要translateable="false"

This should work :D这应该有效:D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式设置adUnitId? - How can I set the adUnitId programmatically? 如何使用 Java 设置 AdUnitId? - How can I set AdUnitId using Java? Android:我可以使用edittext ..修改AdUnitId吗? - Android : Can I Modify AdUnitId using edittext..? 我想将我从字符串中获得的字符串传递给onPostExecute方法 - I want to pass the string that I got from the string to the onPostExecute method 我想从txt文件读取并写入现有的JTable - I want to read from a txt file and write to an existing JTable 我想创建一个文本文件,其名称来自用户并在其中写入? - I want to create a text file with name coming from user and the write in it? 我想在字符串中获取用户输入并使用 java 将该字符串写入文本文件中。 但有个问题 - I want to take user input in string and write that string in a text file using java. But there is a problem 我想通过回调 <T> 将String反序列化为JSON,我写了这个,但是我不能使用 - I want through the Callback<T> to deserialize String to JSON , and I write this but i can't use 我想拆分字符串 - I want to split the string 如何从ArrayList获取String [] <String[]> ,我实际上想从ArrayList的索引0获得String <String[]> ? - How to get String[] from ArrayList<String[]>, I want to actually get String at index 0 from ArrayList<String[]>?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM