public void pause() {
isRunning = false;
while (true) {
try {
ourThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
break;
}
ourThread = null;
}
public void resume() {
isRunning = true;
ourThread = new Thread(this);
ourThread.start();
}
当我进入主屏幕时,这完全正常,但我对如何显示菜单和操作它感到困惑。
答案 0 :(得分:1)
您是否考虑使用弹出式菜单?您可以在pause()上执行showPopup()操作。然后,您可以单击屏幕上的任意位置以关闭弹出窗口,或者您可以在onMenuItemClick中设置简历
这有意义吗?
public void showPopup() {
// Anchor popoup with layout to "center" menu
RelativeLayout layout = (RelativeLayout) findViewById(R.id.menuLayout);
PopupMenu popup = new PopupMenu(this, layout);
popup.setOnMenuItemClickListener(this);
popup.getMenuInflater().inflate(R.layout.menu, popup.getMenu());
popup.show();
}
@Override
public void onMenuItemClick(MenuItem item) {
dosomething();
resume();
}
答案 1 :(得分:0)
单击设备上的菜单按钮时调用pause()。