間で変数を渡す:エラーこれは私のManual.javaファイルで活動
public class Manual extends Activity implements OnClickListener{
Button create;
TextView gotAnswer, NoAnsV;
EditText NoQues, NoAnswer;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.manualask);
NoQues = (EditText) findViewById (R.id.NoQues);
NoAnswer = (EditText) findViewById (R.id.NoAnsw);
create = (Button) findViewById (R.id.create);
create.setOnClickListener(this);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()){
case R.id.create:
Intent intent = new Intent(Manual.this, MCQSample.class);
Bundle b = new Bundle();
Integer Number = Integer.parseInt(NoQues.getText().toString());
intent.putExtras(b);
startActivity(intent);
finish();
break;
}
}
}
その後MCQSample.java:
public class MCQSample extends Activity{
TextView title;
String gotBread;
int value;
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mcqsample);
title = (TextView) findViewById(R.id.abc);
Bundle b = getIntent().getExtras();
int value = b.getInt("key", 0);
title.setText(value);
}
}
その後mcqsample.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Text"
android:id="@+id/abc"/>
</LinearLayout>
両方私が既にAndroidManifestに追加したクラス。
Manual.javaで[作成]ボタンをクリックすると、常にクラッシュします。私の授業に何が悪いですか?あなたがバンドルに番号を設定しない
ああTKSヨタバイト。私は一日中この部分をくっついた! ~~。私はちょうどAndroidを学んだ –
あなたを歓迎します。幸せなコーディング:) – MByD
btw最後の質問、私たちはどのようにintの代わりに配列を転送できますか?方法は同じですか? –