私はAndroid開発に非常に慣れていません。新しいプロジェクトを作成し、グラフィカル レイアウトを使用してボタンを追加し、それを参照しようとすると、ボタンが見つかりません。
「クリーン...」を実行しても機能しない場合があります。また、Eclipseの再起動が機能する場合と機能しない場合があります。
日食は本当に不安定ですか、それとも何か間違ったことをしていますか?
また、私は他の人のすべての投稿を調べたことを言及する必要があります (この質問がよく聞かれることは知っています) が、まだ回答が見つかりません
.java ファイルは次のとおりです。
package com.example.testapp;
import com.example.testapp.R;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.Button;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
}
}
ここに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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:text="Button" />
</RelativeLayout>