小控件的使用

1、当点击Menu键时,如果希望弹出菜单,则希望重写的方法如下:

 

 

     @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	// TODO Auto-generated method stub
    	
    	menu.add(0,0,0,"first");
    	menu.add(0,1,1,"second");
    	menu.add(0,1,2,"third");
    	menu.add(1,0,0,"four");
    	return super.onCreateOptionsMenu(menu);
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	// TODO Auto-generated method stub
    	
    	openOption();  //为自己处理的代码
    	return super.onOptionsItemSelected(item);
    }

 

 

2 、myDialog = ProgressDialog.show(this, title, message);

		
		new Thread(){
			
			@Override
			public void run() {
				try {
					sleep(4000);//自己的业务代码
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}finally{
					myDialog.dismiss();  //一定要调用,不然回不到主页面了
				}
			}
			
			
		}.start();

你可能感兴趣的:(java)