標籤:android style color io strong sp on 問題 代碼
============問題描述============
以下紫色代碼會出導致程式停止運行,請各位協助解決,告知為小弟原因。
public void onConfigurationChanged(Configuration newConfig) {
mnewConfig=newConfig;
Message message = new Message();
message.what = updateUi;
uiHandler.sendMessage(message);
}
[color=#CC99FF]
private Handler uiHandler = new Handler()
{
public void handleMessage(Message msg)
{
if (msg.what==updateUi)
onConfigurationChanged(mnewConfig,mtmp);
}
};
[/color]
public void onConfigurationChanged(Configuration newConfig,int tmp) {
Toast.makeText(ConversationList.this, "new onConfigurationChanged", Toast.LENGTH_LONG).show();
super.onConfigurationChanged(newConfig);
}
如果不執行uiHandler.sendMessage(message);而是直接調用onConfigurationChanged(Configuration newConfig,int tmp)
加以替代就沒有問題,為什麼會這樣
============解決方案1============
你這樣出現死迴圈,不斷得調用onConfigurationChanged,堆棧會滿,自然程式會崩潰!
============解決方案2============
你這是一個死迴圈,將onConfigurationChanged(mnewConfig,mtmp);移到訊息處理函數外,或者在onConfigurationChanged(mnewConfig,mtmp);中不要執行uiHandler.sendMessage(message);
============解決方案3============
這不是死迴圈嗎?
Android Handler求助