Frage

Ok i am developing a cows and bulls game, i am confused how to print messages to the user, i dont want to use dialogs or toasts! As far as i know, the only way is to update textviews , is that the only other option? or can i use something else to display stuff on the screen? my code till now :

public class Play extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.play);
    CowsNBulls();
}

private void CowsNBulls() {
    // TODO Auto-generated method stub
    int target=0;
    final String targetStr = target +"";
    boolean guessed= false;
    final int guess;
    final String Sguess;
        System.out.print("Guess a 4-digit number with no duplicate digits");
        EditText guess1 = (EditText)findViewById(R.id.etGuess);
        Sguess=guess1.getText().toString();
        Button ent = (Button) findViewById(R.id.bEnter);
        guess= Integer.parseInt(Sguess);
        ent.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                int guesses=0;
                int bulls=0;
                int cows=0;
                if(hasDupes(guess)||guess < 1000){
                    guesses++;
                    String guessStr = guess + "";
                    for(int i= 0;i < 4;i++){
                        if(guessStr.charAt(i) ==   targetStr.charAt(i)){
                            bulls++;
                        }else if(targetStr.contains(guessStr.charAt(i)+"")){
                            cows++;
                        }}}}});    

any ideas?

War es hilfreich?

Lösung

TextView or EditText will be your only possibility. You'd have to attach it to the Layout and maybe even wrap it in a ScrollView to make room for enough statements.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top