0

代码显示 eclipse 中没有错误,但是在 android 模拟器中运行它时不幸显示消息,“应用程序名称”已停止。我和我也试图在按钮上链接一个 xml 另一个页面点击我怎么能这样做任何人都可以帮助我,因为我是 android 开发的新手。

清单.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.nikesh.theater"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="9" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.nikesh.theater.Main"
            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>

main.java

package com.nikesh.theater;

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

public class main extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        super.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;
    }


}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/ticket"
    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=".Main" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button2"
        android:layout_alignParentRight="true"
        android:gravity="fill_vertical|center"
        android:text="@string/cam" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/button1"
        android:gravity="fill_vertical|center"
        android:text="@string/list" />

</RelativeLayout>
4

1 回答 1

0

改变:

<activity
        android:name="com.nikesh.theater.Main"
        android:label="@string/app_name" >

至:

<activity
        android:name="com.nikesh.theater.main"
        android:label="@string/app_name" >

当您在清单中main使用时,您的 Java 文件称为。MainAndroid(Java,更准确地说是区分大小写的。

此外,您应该更改super.setContentView(R.layout.activity_main);为 just setContentView(R.layout.activity_main);

您应该做的另一个更改是更改tools:context=".Main"tools:context=".main"与清单中的更改相同的原因

于 2013-03-01T12:52:22.370 回答