在Android屏幕上打印东西

时间:2012-07-22 10:42:13

标签: android system.printing

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

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

任何想法?

1 个答案:

答案 0 :(得分:1)

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