0

コードはEclipseにエラーがないことを示していますが、Androidエミュレーターで実行中に残念ながら「アプリケーション名」が停止したというメッセージが表示されます。私と私はまた、ボタンをクリックしてxmlを別のページにリンクしようとしています.どうすればいいですか.

マニフェスト.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 に答える