私はAndroidが初めてです。ボタン付きの EditText に応じて TextView を変更する簡単なコードを書いています。コードにエラーはありません。しかし、デバイスから実行すると強制終了します。
これが私のコードです:
public class MainActivity extends Activity {
//EditText et = (EditText)findViewById(R.id.editText1); << Error if uncomment
//TextView tv = (TextView)findViewById(R.id.textView1); << Error if uncomment
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
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;
}
}