public void closeOptionsMenu ()
Since: API Level 1 Progammatically closes the options menu. If the options menu is already closed, this method does nothing. Activity里面的这个函数,关闭的是神马menu?
Since: API Level 1 Progammatically closes the options menu. If the options menu is already closed, this method does nothing. Activity里面的这个函数,关闭的是神马menu?
解决方案 »
- android中出现inalizing a Cursor that has not been deactivated or closed.
- android调用jni实现surface抓图的疑惑
- android如何得到服务端的返回值 集合类型
- 菜鸟问题:建立菜单时出错
- expandableListView出现的错误
- BroadcastReceiver ?
- 求助:cannot be cast to java.io.Serializable
- 有没有跨平台的移动开发框架能支持:多线程,Tcp/Udp协议,音频和视频?
- android xml布局文件中控件属性的官方文档在哪看
- javaweb的服务器,找人做了一个安卓壳子,但是安卓8,mui返回按钮不能用
- Android 中出现这样的警告 Exported service does not require permission
- 无需事件就触发一个动作,怎么做?
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;public class HelloActivity extends Activity {
private Button button = null;
private TextView tx = null;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
HelloActivity.this.closeOptionsMenu();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
menu.add(0, 1, 1, "about");
menu.add(0,2,2,"exit");
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onMenuItemSelected(int featureId, MenuItem item) {
// TODO Auto-generated method stub
if(item.getItemId() == 1){
Toast.makeText(HelloActivity.this, "about", Toast.LENGTH_SHORT).show();
}
else if(item.getItemId() == 2){
Toast.makeText(HelloActivity.this, "exit", Toast.LENGTH_SHORT).show();
}
return super.onMenuItemSelected(featureId, item);
}
}我也是这么理解的,怎么没有效果呢?
public void closeOptionsMenu() {
// TODO Auto-generated method stub
Toast.makeText(MainActivity.this, "closeOptionsMenu", Toast.LENGTH_SHORT)
.show();
}
这样就会有反应,希望能帮到你