本人初学,老师让做一个布局已给出代码,但是在我的机子上运行有错,查阅资料改正后运行没有错误也 没有警告。但是最终在安卓手机上运行总是该程序已停止,要么就是该进程无响应。
代码贴出:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView android:id="@+id/TextView01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@+string/hello"
/>
<EditText android:id="@+id/EditText01"
android:inputType="text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<ImageView android:id="@+id/ImageView01"
    android:contentDescription="@+string/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@+drawable/adr"
/>
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/btn_name"
/>
<Button android:id="@+id/Button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+string/stp_name"
/>
</LinearLayout>
<ProgressBar android:id="@+id/progressbar01"
android:layout_width="fill_parent"
android:layout_height="20dp"
style="?android:attr/progressBarStyleHorizontal"
/>
<SeekBar android:id="@+id/seekbar01"
android:layout_width="fill_parent"
android:layout_height="20dp"
style="?android:attr/progressBarStyleHorizontal"
/>
</LinearLayout>
Android开发Android手机布局动态规划

解决方案 »

  1.   

    android:text
    android:src这两个代码是不是写错了?
    改成把里面的加号+去掉试试
      

  2.   

    android:contentDescription="@+string/desc"android:text="@+string/btn_name"这些加号 + 都要去掉
      

  3.   

    package com.example.test2;import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;public class MainActivity extends Activity {    @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
        
    }
      

  4.   

    把+去掉,然后去res/values/strings.xml里加入
    <string name="desc">内容</string>
    <string name="btn_name">内容</string>
    这样就不会报错了,如果没有strings.xml,自己建一个文件
      

  5.   


    我也是刚接触,以我的教训来看,很可能是Activity没有在Manifest中注册
      

  6.   

    谢谢 ,按你说的消除了string的错误,但是android:src="@+drawable/adr"的错误要怎么办呢?
    错误:error: Error: No resource found that matches the given name (at 'src' with value '@drawable-ldpi/adr').我新建了一个名为adr的图片放在drawable-ldpi文件夹下还是没用。
      

  7.   


    我也是刚接触,以我的教训来看,很可能是Activity没有在Manifest中注册
    我应该注册了啊 ,你看:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.test2"
        android:versionCode="1"
        android:versionName="1.0" >    <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="17" />    <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.test2.MainActivity"
                android:label="@string/app_name" >
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application></manifest>
      

  8.   

    其实drawable也是一样的道理,把+号去掉,在res/drawable-ldpi里加入图片。
    一般这个+只在id的时候用到,表示在这里,加一个id,而不是去引用其他的东西
      

  9.   

    嗯。对的,已经解决了。 程序已经能跑了、可是我还看不懂这个程序到底怎么用。按stop停,start开始都没什么反应啊 那个输入框里输入字符也没反应
      

  10.   

    你activity里都没写代码,怎么会有反应呢