我是Android的新开发者。我使用的是ADT 22.3.0(10天前下载)
我打开一个新的Android proyect,当完成并且activity_main打开时,我不能添加任何内容,也不能添加项目或布局。我已经读过我需要一个布局来添加项目(而我的活动没有一个)但是我也不能添加布局。
我的项目配置:
minSDK
:11
targetSDK
:19
我检查了动作栏。
activity_main.xml中
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
</android.support.v4.view.ViewPager>
和SnapShot:
答案 0 :(得分:0)
问题是(我认为)我检查了水平滑动以在操作栏的标签之间移动。此选项创建ViewPager而不是标准布局活动。我手动编辑了XML到&#34;插入&#34; ViewPager在全局布局中,现在我可以添加(或移动)项目 这是新代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="214dp"
android:layout_weight="0.36"
app:context=".MainActivity" >
</android.support.v4.view.ViewPager>
<TextView
android:id="@+id/textView1"
android:layout_width="130dp"
android:layout_height="wrap_content"
android:layout_weight="0.11"
android:text="TextView" />
</LinearLayout>