gpt4 book ai didi

java - 致命异常 : Main Android Eclipse

转载 作者:搜寻专家 更新时间:2023-11-01 08:10:08 27 4
gpt4 key购买 nike

这是我的代码并向我发送错误(致命异常:主要),我想帮助我,非常感谢

这是我在 Activity.java 中的代码

package hola.mundo;

import android.app.Activity;
import android.os.Bundle;

public class HolaActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

这里是我的 main.xml 代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal" >

<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:hint="@string/edit_message" />

<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"/>

</LinearLayout>

和strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Hola</string>
<string name="edit_message">Enter a Message</string>
<string name="button_send">Send</string>

</resources>

谁能帮帮我

最佳答案

您没有为 edit_message 定义的 layout_height(相反,您有:layout_weight)。此外,您的布局可能看起来不像您预期​​的那样,但这是另一个问题(这取决于我现在忽略的您的要求)。

关于java - 致命异常 : Main Android Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10604795/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com