if(++mSpardTimes>6){ return;//这块换成timer.cancel()可能会更好一些,因为return;虽然直接跳出了当前run()方法,什么也没做,但timer还是 会每隔150毫秒进来判断一次,直到程序退出前一直做这样的判断,稍有点耗性能。 }
2015-05-20
代码参考:WordButton wordButton = null;
Random random = new Random();
int index = random.nextInt(mAllWordList.size());
wordButton = mAllWordList.get(index);
if (mCurrentSong.getSongName().contains(wordButton.getContent())) {
// 是答案
findNoAnswerWordButton();
}
return wordButton;
Random random = new Random();
int index = random.nextInt(mAllWordList.size());
wordButton = mAllWordList.get(index);
if (mCurrentSong.getSongName().contains(wordButton.getContent())) {
// 是答案
findNoAnswerWordButton();
}
return wordButton;
2015-05-18
点击已选框的事件处理最好不要直接调用clearTheAnswer()方法,应该做个答案框文字非空串判断,要不然当答案框没有文字时,点击答案框文本按钮还是会执行clearTheAnswer()方法,虽然执行后不影响效果,但显然不应该去作无谓的clearTheAnwer操作,
代码建议:if(!"".equals(wordButton.mWordString)){clearTheAnswer(wordButton)}
代码建议:if(!"".equals(wordButton.mWordString)){clearTheAnswer(wordButton)}
2015-05-17
加了个判断,让随机生成的文字与已经生成的文字进行判断,确保随机生成的汉字不重复,不过这概论好小
//获取随机文字并存入数组
for (int i = mCurrentSong.getNameLength(); i < MyGridView.COUNTS_WORDS; i++) {
for (int j = 0; j < i; j++) {
if ((getRandomChar()+"").equals(words[j])) {
i--;
}else {
words[i]=getRandomChar()+"";
}
}
}
//获取随机文字并存入数组
for (int i = mCurrentSong.getNameLength(); i < MyGridView.COUNTS_WORDS; i++) {
for (int j = 0; j < i; j++) {
if ((getRandomChar()+"").equals(words[j])) {
i--;
}else {
words[i]=getRandomChar()+"";
}
}
}
2015-05-15