Random text, slow and laggy
<p>Hey i am using the code below to use as a press a button to get new text in to a textview,
But its laggy and doesn't work half of the times i press it, but the other half of the time it works fine, anyone have any idé?</p>

<pre><code>final Button button = (Button) findViewById(R.id.slumpaovrigt);
    button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
    Random myRandom5 = new Random();
    TextView textovrigt = (TextView) findViewById(R.id.textovrigt);
    switch(myRandom5.nextInt() %151) {
    case 0:
        textovrigt.setText("text 1");
        break;
    case 1:
        textovrigt.setText("text 2");
        break;
    case 2:
        textovrigt.setText("text 3");
        break;
    case 3:
        textovrigt.setText("text 4");
        break;
    }
    }
    });
    }
    }
</code></pre>

<p>Also, i use 4 different xml views whit the same code but for different buttons and textviews and also whit different texts, each of the contains around 150 different texts (cases).</p>

<p>Changed the code abit and it got better, however still a bit slow</p>

<p>this is the complete code in the java file</p>

<pre><code>import java.util.Random;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Ovrigtskamt extends Activity {

    Button slumpaovrigt;
TextView textovrigt;
Random slumpaovrigt2 = new Random();


@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ovrigttext);
    super.onCreate(savedInstanceState);
    this.setRequestedOrientation(
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);



    slumpaovrigt = (Button) findViewById(R.id.slumpaovrigt);
    textovrigt = (TextView)findViewById(R.id.textovrigt);

    loadDoc();
}

private void loadDoc(){




    String s = "";

    for(int x=0;x&lt;=100;x++){
        s += "Line: "+String.valueOf(x)+"\n";
    }

    textovrigt.setMovementMethod(new ScrollingMovementMethod());

    textovrigt.setText("Klicka på Slumpa");




    slumpaovrigt.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {




    switch(slumpaovrigt2.nextInt() %4) {
    case 0:
  case 0:
    textovrigt.setText("text 1");
    break;
case 1:
    textovrigt.setText("text 2");
    break;
case 2:
    textovrigt.setText("text 3");
    break;
case 3:
    textovrigt.setText("text 4");
    break;
}
}
});
}
}
</code></pre>

<p>but as said whit 151 different texts</p>
