我想从教程中学习滑动技术来更改我的页面。在该教程中,他在主 xml 文件中使用了“android.support.v4.view.ViewPager”。但我不知道我必须在 android studio 环境中的文件中的什么位置附加此代码。我的主要问题是当我在我的 xml 代码的每个地方附加“android.support.v4.view.ViewPager”时,它表示错误并且我不知道哪里是正确的附加位置。这是我的主要 xml 文件:
<RelativeLayout
android.support.v4.view.ViewPager // error is here
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
gradle 中的错误是:
Error:(3) Error parsing XML: not well-formed (invalid token)
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\iman\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1
最佳答案
如下编辑你错过了“<”android.support.v4.view.ViewPager
<RelativeLayout
<android.support.v4.view.ViewPager // error is here
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content" />
关于android - 在 activity_main.xml 文件中导入 "android.support.v4.view.ViewPager",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32593932/