我是一名新開發人員,在設置覆蓋我的UI的佈局的可見性以在運行腳本時禁用它時遇到問題。setvisibility中的應用程序崩潰android
這裏是我的代碼:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch (item.getItemId()) {
case R.id.action_settings:
return true;
case R.id.action_loadfile:
saveTellNamesArray();
LoadFile(txtFolder, ScriptArray);
return true;
case R.id.action_runscript:
disableLayout();
stopScript = false;
scriptThread = new Thread(new Runnable() {
@Override
public void run() {
while (!scriptThread.isInterrupted() && !stopScript) {
runScript();
}
if (stopScript)//revisar
enableLayout();
}
});
scriptThread.start();
//enableLayout();
return true;
case R.id.action_stopscript:
if (scriptThread != null) {
//scriptThread.interrupt();
stopScript = true;
}
return true;
default:
return super.onOptionsItemSelected(item);
}
}
的問題是,應用程序,只要我調用enableLayout()函數崩潰:
public void disableLayout() {
uiBlockLayout.setVisibility(FrameLayout.VISIBLE);
uiBlockLayout.bringToFront();
}
public void enableLayout() {
uiBlockLayout.setVisibility(FrameLayout.GONE);
}
什麼問題可能是任何線索?
請,** **份額的**記錄錯誤**。 – Nawako
Nawako說了些什麼,再加上'uiBlockLayout'被賦值的範圍。 – Mena
謝謝大家,由@ρяσѕρєяK給出的答案是正確的。感謝您的時間。 – Sombrero22