EditTextオブジェクトが参照されているときに、onClickメソッドでエラーが発生しています。ここでアンドロイドウィジェットのヌルポインタ例外EditText?
public class messageActivity extends AppCompatActivity {
EditText editText;
Button button;
Logic logic;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
editText = (EditText) findViewById(R.id.editText);
button = (Button) findViewById(R.id.button6);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
logic.message(editText.getText().toString());
}
});
}
}
私の活動のEditText
ウィジェットのXMLです:
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_below="@+id/textView3"
android:layout_centerHorizontal="true"
android:layout_marginTop="83dp"
android:inputType="textShortMessage"
android:editable="false" />
ロジック変数はどこで初期化しますか?これはここではnullポインタのようです。あなたのlogcatを掲示してください –