我正在尝试构建一个应用程序,其中屏幕左侧有一个图像,右侧有一个写评论的地方(动态分配文本视图)。我在尝试将 Linearlayout 放置在 Relativelayout 中时遇到了错误。
以下是我的 xml 文件代码(减去几个按钮):
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<com.example.blueprintproj.PaintView
android:id="@+id/paintView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/loadButton"
android:background="@drawable/bp2" />
<Linearlayout
android:id="@+id/linearLayout"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true" >
<EditText
android:id="@+id/editText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add+"
/>
</Linearlayout>
以下是我尝试运行时收到的错误消息:
07-10 02:35:50.207: E/AndroidRuntime(786): FATAL EXCEPTION: main
07-10 02:35:50.207: E/AndroidRuntime(786): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.blueprintproj/com.example.blueprintproj.MainActivity}: android.view.InflateException: Binary XML file line #80: Error inflating class Linearlayout
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.ActivityThread.access$600(ActivityThread.java:141)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.os.Handler.dispatchMessage(Handler.java:99)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.os.Looper.loop(Looper.java:137)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-10 02:35:50.207: E/AndroidRuntime(786): at java.lang.reflect.Method.invokeNative(Native Method)
07-10 02:35:50.207: E/AndroidRuntime(786): at java.lang.reflect.Method.invoke(Method.java:511)
07-10 02:35:50.207: E/AndroidRuntime(786): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-10 02:35:50.207: E/AndroidRuntime(786): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-10 02:35:50.207: E/AndroidRuntime(786): at dalvik.system.NativeStart.main(Native Method)
07-10 02:35:50.207: E/AndroidRuntime(786): Caused by: android.view.InflateException: Binary XML file line #80: Error inflating class Linearlayout
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-10 02:35:50.207: E/AndroidRuntime(786): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.Activity.setContentView(Activity.java:1881)
07-10 02:35:50.207: E/AndroidRuntime(786): at com.example.blueprintproj.MainActivity.onCreate(MainActivity.java:42)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.Activity.performCreate(Activity.java:5104)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
07-10 02:35:50.207: E/AndroidRuntime(786): ... 11 more
07-10 02:35:50.207: E/AndroidRuntime(786): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.Linearlayout" on path: /data/app/com.example.blueprintproj-1.apk
07-10 02:35:50.207: E/AndroidRuntime(786): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
07-10 02:35:50.207: E/AndroidRuntime(786): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-10 02:35:50.207: E/AndroidRuntime(786): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
07-10 02:35:50.207: E/AndroidRuntime(786): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
07-10 02:35:50.207: E/AndroidRuntime(786): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
请让我知道我做错了什么,或者如果您需要指出问题的任何其他信息!
太感谢了!