【问题标题】:this program failed to install on emulator or mobile phone. why?该程序无法在模拟器或手机上安装。为什么?
【发布时间】:2012-08-30 12:26:18
【问题描述】:

我编写程序并尝试运行该程序,但该程序有 2 个警告 :( 当我尝试使用模拟器运行时,程序失败。当我使用手机运行时,即使手机断开连接,手机也会挂起用pc,手机还挂着:(

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:background="@color/background"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="30dip"
    android:orientation="horizontal">
    <LinearLayout
        android:orientation="vertical"
        android:layout_height="wrap_content"
        android:layout_width="fill_parent"
        android:layout_gravity="center">
        <TextView
            android:text="@string/main_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:layout_marginBottom="25dip"
            android:textSize="24.5sp"/>
        <Button
            android:id="@+id/continue_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/continue_label"/>
        <Button
            android:id="@+id/new_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/new_game_label"/>
        <Button
            android:id="@+id/about_button"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/about_label" />
        <Button 
        android:id="@+id/exit_button"
    android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/exit_label"/>
  </LinearLayout>


字符串.xml

 <resources>
  <string name="app_name">Sudoku</string>
  <string name="menu_settings">Menue</string>
  <string name="title_activity_main">MianActivity</string>
  <string name="main_title">Android Sudoku</string>
  <string name="continue_label">Continue</string>
  <string name="new_game_label">New Game</string>
  <string name="about_label">About</string>
  <string name="exit_label">Exit</string>

 </resources>

和 AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="org.example.sudoku"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".MainActivity"
            android:label="@string/title_activity_main" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

和警告错误是: 第 9 行的 --> 这个 LinearLayout 布局或者它的 LinearLayout 父级是没用的;将背景属性转移到另一个视图

第 13 行 --> 在布局文件中发现意外的文本:“””

【问题讨论】:

  • 发布你的清单文件和一些代码
  • 请把您的一些代码,以便我们更好地理解您的问题。

标签: android android-emulator mobile-emulator


【解决方案1】:

这里不需要嵌套的 LinearLayout。因为第一个 LinearLayout 没有其他子级。删除第一个 LinearLayout。没用。

【讨论】:

  • 感谢您的回答。我删除了第一个 LinearLayout 但程序出现 2 个错误和 27 个警告!我该怎么办?
  • 我在Hello Android一书中读到了这段代码,我不知道为什么要写两个LinearLayout。我可能是其中之一,或者移居其他人?
  • 我解决了问题,我再次编写代码并运行程序,但仍然出现警告。我不知道为什么会出现警告以及程序是如何解决的!!
猜你喜欢
  • 1970-01-01
  • 2016-02-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-09-30
  • 1970-01-01
相关资源
最近更新 更多