Androidスタジオを学習しようとしていますが、これは初めてのことです。私は単純なログインアプリを作ろうとしており、2つのEditText
フィールドを追加しましたが、認識されません。Android Studioで入力フィールドが認識されない「フィールドは使用されていません」
このエラーが発生します。
Cannot resolve symbol EditText
私は自分のアプリケーションでEditText
フィールドを持っていることを確認しましたが。
これは、Javaコードです:
package localhost.testloginphpapp;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
EditText usernameField, passwordField;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
とXMLコード:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="localhost.testloginphpapp.MainActivity"
tools:layout_editor_absoluteY="81dp"
tools:layout_editor_absoluteX="0dp">
<EditText
android:id="@+id/usernameField"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPersonName"
android:text="Username"
tools:layout_editor_absoluteX="85dp"
tools:layout_editor_absoluteY="133dp" />
<EditText
android:id="@+id/passwordField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textPassword"
tools:layout_editor_absoluteX="85dp"
tools:layout_editor_absoluteY="190dp" />
<Button
android:id="@+id/loginButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Login"
tools:layout_editor_absoluteX="148dp"
tools:layout_editor_absoluteY="245dp" />
</android.support.constraint.ConstraintLayout>
どうもありがとうございました。あなたがパッケージの下が、クラスの前のコード行を記述する必要があり
これはあなたの完全なコードのですか?なぜなら、あなたがそれらにアクセスする前に初期化していないときに普通にスローされるからです。 – BAAAZINGA
@ BAAAZINGAそれはすべてです。 – user6613235
それは "彼ら"と言って、 "themä"になることが判明しているはずです: ') – BAAAZINGA