繁体   English   中英

启动后android应用程序崩溃

[英]android application crash after launch

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.Resources $ NotFoundException :字符串资源ID#0x66。 并暗恋设备。已经1个小时,我正在尝试查找问题。 请帮我

谢谢,我已经找到了解决方案。 我写了tvresult.setText(generacvac); 但它强制转换为int,我需要编写tvresult.setText(generacvac +“”)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM