なぜうまくいかないのか誰か教えてもらえますか?Eclipse はコンパイル時にエラーを表示しませんが、Android エミュレーターは 76 行目でクラッシュします: " intrebare.setText("Intrebarea " + i+1 + ": " + intrebari[i]);" プログラム全体は次のようになります。
package com.example.testpsiho1;
import android.os.Bundle;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.app.AlertDialog;
import android.support.v4.app.NavUtils;
public class TestPsiho extends Activity {
public static Button btna, btnb, btnc;
public static TextView titlu, intrebare;
public static String[] intrebari = {"intrebare 1", "intrebare 2", "intrebare 3"};
public static String[] raspunsuriA = {"rasp a 1", "rasp a 2", "rasp a 3"};
public static String[] raspunsuriB = {"rasp b 1", "rasp b 2", "rasp b 3"};
public static String[] raspunsuriC = {"rasp c 1", "rasp c 2", "rasp c 3"};
public static String[] rezultate = {"rezultatul pentru cele mai multe rasp a", "rezultatul pentru cele mai multe rasp b", "rezultatul pentru cele mai multe rasp c"};
public static int a=0, b=0, c=0, i=1;
public static String rezultat="";
AlertDialog.Builder alert;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test_psiho);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
public void click(View v){
btna=(Button)findViewById(R.id.btna);
btnb=(Button)findViewById(R.id.btnb);
btnc=(Button)findViewById(R.id.btnc);
intrebare=(TextView)findViewById(R.id.intrebare);
if(i<4){
if (v.equals(btna)) a++;
if (v.equals(btna)) b++;
if (v.equals(btna)) c++;
intrebare.setText("Intrebarea " + i+1 + ": " + intrebari[i]);
btna.setText(raspunsuriA[i]);
btnb.setText(raspunsuriB[i]);
btnc.setText(raspunsuriC[i]);
}
if(i==4){
if (a >= b && a >= c){
alert=new AlertDialog.Builder(this);
alert.setTitle("bla bla bla");
}
}
i++;
}
}