どこでも検索しましたが、問題に対する答えが見つかりません。私はこれにまったく慣れておらず、頭を悩ませています。Android 開発サイトから基本的な「初めてのアプリ チュートリアル」を実行しているだけです。コードが例に書かれているとおりであっても、チュートリアルではエラーが発生します。コンソールに表示されるエラーは次のとおりです。
[2013-03-12 15:33:36 - MyFirstApp] D:\Android Development\MyFirstApp\res\menu \main.xml:3: error: Error: No resource found that matches the given name (at 'title' with value '@string/action_settings').
[2013-03-12 15:34:38 - MyFirstApp] W/ResourceType( 6352): Bad XML block: header size 311 or total size 5346560 is larger than data size 0
私が変更したのは、チュートリアルで変更するように言われたものだけです。 Activity_main.xml
とstrings.xml
。で何も変更したことはありませんmain.xml
。パッケージ エクスプローラーでは、横に赤い x が表示 され、括弧内にエラーがある MainActiviy のコードは次MainActivity>onCreate(Bundle)
のとおりです。onCreateOptionsMenu(Menu)
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); (error here red underline under R)
}
@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); (error here red underline under R)
return true;
}
}
私は何を間違えましたか?私はこれを学び始めたばかりで、チュートリアルを正しく実行することさえできないようです!
指示に従って変更した Activity_main.xml と strings.xml を次に示します。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal"
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" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="horizontal"
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" >
<EditText android:id="@+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>
助けてくれてありがとう。