【问题标题】:Can't add items (neither layout) to activity (ADT)无法将项目(两种布局)添加到活动(ADT)
【发布时间】:2014-04-25 10:38:38
【问题描述】:

我是 Android 的新开发者。我正在使用 ADT 22.3.0(10 天前下载)。
我打开了一个新的 Android 项目,当完成和 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

【问题讨论】:

  • 转到文件-新建-xml文件-创建
  • 我会试试,但有什么问题?我想了解更多关于 ADT 的信息
  • 清理你的项目并从“项目”菜单构建并检查它

标签: android eclipse android-layout adt


【解决方案1】:

问题是(我认为)我检查了水平滑动以在操作栏的选项卡之间移动。此选项创建 ViewPager 而不是标准布局活动。我手动编辑 XML 以在全局布局中“插入”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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多