Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何在layout.xml中声明元素_Android_Xml_Eclipse_Sdk - Fatal编程技术网

Android 如何在layout.xml中声明元素

Android 如何在layout.xml中声明元素,android,xml,eclipse,sdk,Android,Xml,Eclipse,Sdk,今天我刚开始玩android/sdk,对于这个愚蠢的问题我很抱歉,但我正在学习 我正在使用eclipse,我已经在我的项目的java文件中添加了一些代码,以便将应用程序连接到adserver,它工作正常,当我启动应用程序时,我会收到我的广告横幅。 我已经导入了android sdk和AdService provider sdk 现在,我想在布局xml中创建的一些对象之间插入横幅 因此,我在layout文件夹下有fragment_main.xml,我在其中放置了以下xml: <Lin

今天我刚开始玩android/sdk,对于这个愚蠢的问题我很抱歉,但我正在学习

我正在使用eclipse,我已经在我的项目的java文件中添加了一些代码,以便将应用程序连接到adserver,它工作正常,当我启动应用程序时,我会收到我的广告横幅。 我已经导入了android sdk和AdService provider sdk

现在,我想在布局xml中创建的一些对象之间插入横幅

因此,我在layout文件夹下有fragment_main.xml,我在其中放置了以下xml:

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:opensdk="http://schemas.android.com/apk/res/com.example.myfirstapp"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal" >

    <Button
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="@string/button_send"
       android:onClick="sendMessage" />


    <com.appnexus.opensdk.BannerAdView
       android:id="@+id/banner"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:placement_id="YOUR PLACEMENT ID"
       android:auto_refresh="true"
       android:auto_refresh_interval="30"
       android:opens_native_browser="true"
       android:adWidth="320"
       android:adHeight="50"
       android:should_reload_on_resume="true"
       android:opens_native_browser="true"
       android:expands_to_fit_screen_width="false"
       />
那么,我在哪里声明所有这些属性呢?它必须与此路径有关: xmlns:opensdk=”http://schemas.android.com/apk/res/com.example.myfirstapp"

请让我知道,如果你可以帮助,并为可怜的信息抱歉

改变这个

<com.appnexus.opensdk.BannerAdView
       android:id="@+id/banner"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:placement_id="YOUR PLACEMENT ID"
       android:auto_refresh="true"
       android:auto_refresh_interval="30"
       android:opens_native_browser="true"
       android:adWidth="320"
       android:adHeight="50"
       android:should_reload_on_resume="true"

       android:expands_to_fit_screen_width="false"
       />
正如你所看到的- 要使用appnexus,您应该执行以下操作:

第一步。下载代码

如果您有gitbash,可以使用以下命令从github下载它git@github.com:appnexus/mobilesdk android.git

您也可以转到
https://github.com/appnexus/mobile-sdk-android
使用浏览器,并将其下载到.zip文件中

第二步。将appnexus SDK导入为库

使用Android IDE将sdk目录作为库导入工作区

第三步。添加活动

您必须将以下活动添加到清单中,SDK才能正常运行:

<application
  <activity android:name="com.appnexus.opensdk.AdActivity" />
</application>


@西蒙尼如果解决了,请接受它,这样它也可以帮助其他人
<com.appnexus.opensdk.BannerAdView
       android:id="@+id/banner"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:placement_id="YOUR PLACEMENT ID"
       android:auto_refresh="true"
       android:auto_refresh_interval="30"
       android:opens_native_browser="true"
       android:adWidth="320"
       android:adHeight="50"
       android:should_reload_on_resume="true"

       android:expands_to_fit_screen_width="false"
       />
  <com.appnexus.opensdk.BannerAdView
           android:id="@+id/banner"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           opensdk:placement_id="YOUR PLACEMENT ID"
           opensdk:auto_refresh="true"
           opensdk:auto_refresh_interval="30"
           opensdk:opens_native_browser="true"
           opensdk:adWidth="320"
           opensdk:adHeight="50"
           opensdk:should_reload_on_resume="true"

           opensdk:expands_to_fit_screen_width="false"
           />
xmlns:opensdk="http://schemas.android.com/apk/res/com.example.myfirstapp"
<application
  <activity android:name="com.appnexus.opensdk.AdActivity" />
</application>
<!-- Add the permissions here... -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />