0
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。並暗戀device.Already 1小時我試圖找到問題。請幫我的Android應用程序崩潰
提供完整的日誌跟蹤 –
顯示您activity_game – KDeogharkar
它的遊戲活動 –