启动后的Android应用程序崩溃

时间:2016-06-09 17:26:05

标签: java android

public class Game extends AppCompatActivity {
static int i = 0;
static  int p = 0;

String porc0;
TextView tvporc;
Button btn;
TextView tvresult;
String mutqbar;
char generacvac;
char mutq;
int mutqitiv;
int generacvacitiv;
EditText et;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game);
    Random random = new Random();
    btn = (Button) findViewById(R.id.button4);
    tvporc=(TextView) findViewById(R.id.tvPorc);
    tvresult=(TextView) findViewById(R.id.result);
    generacvac=(char)(random.nextInt(26)+'a');
    tvresult.setText(generacvac);
    generacvacitiv = (int) generacvac;
    et=(EditText) findViewById(R.id.editText2);
    tvresult.setText(generacvac);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            mutqbar = et.getText().toString();
            try {
                mutq = mutqbar.charAt(0);
                mutqitiv = (int) mutq;
                if (mutqitiv<97 || mutqitiv>122){
                    tvporc.setText("Մուտքագրեք տառ");
                }
                int abs = Math.abs(mutqitiv-generacvacitiv);
                if (abs>0 && abs<5) tvresult.setText("Դու շատ մոտ ես!");
                else if (abs>=5 && abs<10) tvresult.setText("Դու մոտ ես~");
                else if(abs>=10) tvresult.setText("Դու հեռու ես~");

            } catch (Exception e1) {
                tvresult.setText("Դաշտը դատարկ է");
            }


        }

    });



}}

我有这段代码,但是当我运行它时,它返回错误java.lang.RuntimeException:无法启动活动ComponentInfo {com.guessit.guessit / com.guessit.guessit.Game}:android.content.res。资源$ NotFoundException:字符串资源ID#0x66。并且粉碎了设备。已经有1个小时我试图找到问题。请帮帮我

1 个答案:

答案 0 :(得分:0)

谢谢,我已经找到了解决方案。我写了tvresult.setText(generacvac);但它转换为int,我需要写tvresult.setText(generacvac +&#34;&#34;)