Q: Android Emulator crashes - the incrementing doesn't work Can someone tell me why it doesn't work? The eclipse doesn't show any erros when i compile but the android emulator crashes at line 76: " intrebare.setText("Intrebarea " + i+1 + ": " + intrebari[i]);" The entire program looks like this:
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++;

}
}


A: You need to wrap your increment:
(i + 1)

As in:
intrebare.setText("Intrebarea " + (i+1) + ": " + intrebari[i]);


A: It doesn't work because your "i+1" is assumed as a string.
I don't know if its the best option but you can resolve your issue replacing your setText method with :
intrebare.setText(String.formatString("Intrebarea %s: ", i+1).concat(intrebari[i]));

