TextView
計算結果をまたはに表示しようとしていますEditText
。one100lbsとtenPoundsからユーザー入力を取得し、それを合計して、totalPoundsに表示しようとしています。これは私が使用する方程式ではありませんが、それが機能することを確認したいだけです。現在、以下のコードでアプリケーションがクラッシュします。これはすべて1つ未満activity
です。また、変更EditText
の場所のIDを変更するとどうなりますか?リンクを付けないでください、私はその単純さを知っていますが、私は初心者です。私は検索しましたが、解決策を見つけるのに苦労しています。editText
relative layout
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pounds);
addListenerOnSpinnerItemSelection();
EditText one100lbs = (EditText) findViewById(R.id.one100lbs);
int one = Integer.valueOf(one100lbs.getText().toString());
EditText tenPounds = (EditText) findViewById(R.id.tenPounds);
int two = Integer.valueOf(tenPounds.getText().toString());
int result = one + two;
TextView textView = (TextView) findViewById(R.id.totalPounds);
textView.setText(result);
}