android 全屏代码

 //无title       requestWindowFeature(Window.FEATURE_NO_TITLE);       //全屏      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN); 
或使用配置。在当前Activity中使用主题
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"  

屏目横竖切换、

 //如果是竖排,则改为横排  if(getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE)    { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);   }  //如果是横排,则改为竖排else if(getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }

给Activity 添加menu.

 public boolean onCreateOptionsMenu(Menu menu) {        menu.add(0, 0, 0, "关于"); //参数1:组名,参数2:item的值,参数3:排序,参数4:menu展示的值        menu.add(0, 1, 1, "退出");        menu.add(1, 0, 0, "退出");        menu.add(1, 1, 1, "退出");        return super.onCreateOptionsMenu(menu);    }     //菜单响应    public boolean onOptionsItemSelected(MenuItem item) {        super.onOptionsItemSelected(item);                if(item.getGroupId()==1){        switch (item.getItemId()) {case 0:this.finish();break;case 1:this.finish();break;default:break;}        }else{            switch (item.getItemId()) {            case 0:                Toast.makeText(this, "欢迎", Toast.LENGTH_LONG).show();                   break;            case 1:                this.finish();                break;            case 2:            this.finish();            break;            }        }           return true;    } 


RatingBar 的使用

<RatingBar     android:id="@+id/ratingBar"     android:numStars="5"     android:rating="1.5"     android:layout_width="wrap_content"     android:layout_height="wrap_content">   </RatingBar>

  RatingBar bar = (RatingBar) this.findViewById(R.id.ratingBar);       bar.setRating(2.5f);        bar.getRating();           bar.setOnRatingBarChangeListener(new OnRatingBarChangeListener(){        @Override            public void onRatingChanged(RatingBar ratingBar, float rating,  boolean fromUser) {        System.out.println("ratingBar:"+ratingBar.getRating());       System.out.println("rating:"+rating);           }        });
效果图:



Tosat 弹出带图片的提示。

Toast toast =Toast.makeText(getApplicationContext(), "用户名不能为空", 0);toast.setGravity(Gravity.CENTER, 0, 0);View toastView = toast.getView();ImageView image = new ImageView(LayoutDemoActivity.this);image.setImageResource(R.drawable.icon1);LinearLayout ll = new LinearLayout(LayoutDemoActivity.this);ll.addView(image);ll.addView(toastView);toast.setView(ll);toast.show();
效果图:



通知:

Intent intent = new Intent(ImageViewActivity.this,OtherActivity.class);PendingIntent contentIntent = PendingIntent.getActivity(ImageViewActivity.this, 0, intent, 0);Notification notify = new Notification();notify.icon=R.drawable.icon1;notify.tickerText="启动otherActivity通知";notify.when=System.currentTimeMillis();notify.defaults=Notification.DEFAULT_SOUND;notify.defaults=Notification.DEFAULT_ALL;notify.setLatestEventInfo(ImageViewActivity.this, "普通通知", "点击查看", contentIntent);NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);manager.notify(0, notify);

检测是否安装内存卡:

    private boolean checkSdcard() {if(Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)){return true;}return false;}


弹出对话框:

 
  ProgressDialog proDialog = ProgressDialog.show(LoginUserActivity.this,"请稍候","正在登陆...", true, true); 
proDialog = new ProgressDialog(LoginUserActivity.this); proDialog.setIcon(R.drawable.icon); proDialog.setTitle("ProgressDialog"); proDialog.setMessage("Please wait while loading application list..."); proDialog.setCancelable(false); proDialog.show(); proDialog.dismiss();

当程序退出时。结束自己的进程。

android.os.Process.killProcess(android.os.Process.myPid());
   

更多相关文章

  1. android双击返回键退出程序
  2. 页面跳转采用滑动效果
  3. android双击返回键退出程序
  4. android双击返回键退出程序
  5. 如何通过代码更改ANDROID的UI布局
  6. Android(安卓)Activity界面切换添加动画特效
  7. android 关于tts的一些参数
  8. android之ListView和SimpleAdapter的组合使用
  9. Android退出程序(三)——Android事件总线

随机推荐

  1. android:layout_weight的真实含义
  2. Android指纹登录工具类封装
  3. Android基础笔记(七)-页面跳转和数据传递
  4. Android(安卓)弹出软键盘android:windowS
  5. Android 多渠道定制化打包
  6. 如何在Android智能手机上捕获数据包
  7. android sdk 安装时无法连接到地址
  8. 《第一行代码(第二版)》学习(二)
  9. android中gravity和layoutgravity的区别
  10. Android入门之Activity的四种启动模式