m_tipView.setText(...)操作前,有必要加if (null != m_tipView)判定吗?private TextView m_tipView;
//设置提示控件
public void setTextView(TextView textView) {
m_tipView = textView;
}public void setMode(int newMode) {
if (READY == newMode) {
m_tipView.setText(R.string.mode_ready);
m_currentMode = READY;
}
else if (RUNNING == newMode) {
m_tipView.setText(null);
m_currentMode = RUNNING;
}
else if (PLAYER1_LOST == newMode) {
m_tipView.setText(R.string.player1_lost);
m_currentMode = READY;
}
else if (PLAYER2_LOST == newMode) {
m_tipView.setText(R.string.player2_lost);
m_currentMode = READY;
}
else {
Log.v(TAG, "m_currentMode is an unknown status");
}
}
//设置提示控件
public void setTextView(TextView textView) {
m_tipView = textView;
}public void setMode(int newMode) {
if (READY == newMode) {
m_tipView.setText(R.string.mode_ready);
m_currentMode = READY;
}
else if (RUNNING == newMode) {
m_tipView.setText(null);
m_currentMode = RUNNING;
}
else if (PLAYER1_LOST == newMode) {
m_tipView.setText(R.string.player1_lost);
m_currentMode = READY;
}
else if (PLAYER2_LOST == newMode) {
m_tipView.setText(R.string.player2_lost);
m_currentMode = READY;
}
else {
Log.v(TAG, "m_currentMode is an unknown status");
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货