0

好的,我正在开发牛和公牛游戏,我很困惑如何向用户打印消息,我不想使用对话框或敬酒!据我所知,唯一的方法是更新 textviews ,这是唯一的其他选择吗?或者我可以用别的东西在屏幕上显示东西吗?我的代码到现在:

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++;
                        }}}}});    

有任何想法吗?

4

1 回答 1

1

TextView 或 EditText 将是您唯一的选择。您必须将其附加到布局,甚至可能将其包装在 ScrollView 中,以便为足够的语句腾出空间。

于 2012-07-22T10:44:34.873 回答