zoukankan      html  css  js  c++  java
  • 高级控件

    信息提示框
    在单击事件中:

    1 public void onClick(View v) {
    2                 Toast.makeText(本类名.this, "提示语", Toast.LENGTH_LONG).show();
    3                     //长时间显示的提示框(LENGTH_SHORT(短时间))
    4     }
    View Code

    警告框(AlertDialog)

    1 Dialog ad = new AlertDialog.Builder(本类名.this)
    2         .setTitle("警告")        //显示标题
    3         .setIcon(R.drawable.icon1)    //drawable的id
    4         .setMessage("吸烟有害身体健康")    //显示信息
    5         .create();            //创建Dialog
    6 ad.show();
    View Code

    对话框退出

     1 Dialog ad = new AlertDialog.Builder(Tishi.this)
     2     .setTitle("程序退出")
     3     .setIcon(R.drawable.icon1)
     4     .setMessage("您确定要退出本程序吗?")
     5     .setPositiveButton("确定",new DialogInterface.OnClickListener() {
     6         public void onClick(DialogInterface dialog, int which) {
     7             Tishi.this.finish();//退出程序
     8         }
     9     })
    10     .setNegativeButton("取消",new DialogInterface.OnClickListener() {
    11         public void onClick(DialogInterface dialog, int which) {
    12                                     
    13         }
    14     })
    15     .setNeutralButton("查看详情",new DialogInterface.OnClickListener() {
    16         public void onClick(DialogInterface dialog, int which) {
    17                                     
    18         }
    19     })
    20     .create();
    View Code

    手机按返回键退出

     1 public boolean onKeyDown(int keyCode, KeyEvent event) {
     2     if(keyCode == KeyEvent.KEYCODE_BACK){//判断是否是返回键
     3         AlertDialog isExit = new AlertDialog.Builder(this)
     4             .setTitle("系统提示")
     5             .setMessage("确定要退出吗")
     6             .setPositiveButton("确定",new DialogInterface.OnClickListener() {
     7                 public void onClick(DialogInterface dialog, int which) {
     8                     Tishi.this.finish();
     9                 }
    10             })
    11             .setNegativeButton("取消",new DialogInterface.OnClickListener() {
    12                 public void onClick(DialogInterface dialog, int which) {
    13                     
    14                 }
    15             })
    16             .create(); 
    17         isExit.show();
    18     }
    19     return false;
    20 }
    View Code

    进度处理对话框

     1 public void onClick(View v) {
     2     final ProgressDialog proDig = ProgressDialog.show(Jindu.this,"搜索网络","请等待....");
     3         new Thread(){//线程对象
     4             public void run(){//线程主体
     5                 try {
     6                     Thread.sleep(3000);//运行3秒后关闭对话框
     7                 } catch (Exception e) {
     8                 } finally{
     9                     proDig.dismiss();//关闭对话框
    10                 }
    11             }
    12         }.start();
    13         proDig.show();
    14 }
    View Code

    拖动条(SeekBar)

    1 <SeekBar
    2       android:id="@+id/seekbar"
    3       android:layout_width="fill_parent"
    4       android:layout_height="wrap_content"
    5 />
    View Code
     1 sk.setProgress(80);//设置默认位置
     2 sk.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
     3     public void onStopTrackingTouch(SeekBar seekBar) {
     4         Jindu.this.tv.append("*** 停止拖动,当前值:"+seekBar.getProgress()+"
    ");
     5     }
     6     public void onStartTrackingTouch(SeekBar seekBar) {
     7         Jindu.this.tv.append("*** 开始拖动,当前值:"+seekBar.getProgress()+"
    ");
     8     }
     9     public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
    10         Jindu.this.tv.append("*** 正在拖动,当前值:"+seekBar.getProgress()+"
    ");
    11     }
    12 });
    View Code

    滚动条视图(ScrollView)

     1 <?xml version="1.0" encoding="utf-8"?>
     2 <ScrollView
     3   xmlns:android="http://schemas.android.com/apk/res/android"
     4   android:layout_width="fill_parent"
     5   android:layout_height="100dp">
     6   <LinearLayout
     7       android:layout_width="wrap_content"
     8       android:layout_height="wrap_content"
     9       android:orientation="vertical"
    10   >
    11       <TextView
    12           android:layout_width="fill_parent"
    13           android:layout_height="wrap_content"
    14           android:layout_marginTop="50dp"
    15           android:text="@string/hello"
    16       />
    17       <TextView
    18           android:layout_width="fill_parent"
    19           android:layout_height="wrap_content"
    20           android:layout_marginTop="50dp"
    21           android:text="@string/hello"/>
    22       <TextView
    23           android:layout_width="fill_parent"
    24           android:layout_height="wrap_content"
    25           android:layout_marginTop="50dp"
    26           android:text="@string/hello"/>
    27   </LinearLayout>
    28 </ScrollView>
    View Code
  • 相关阅读:
    vue过滤器
    laravel service provider(服务提供器)使用场景
    laravel下视图间共享数据的两种方法
    【实例】laravel给所有视图共享数据
    Java并发(八)计算线程池最佳线程数
    mybatis-plus多表联合分页查询
    MybatisPlusException: can not find lambda cache for this entity[]异常解决
    Swagger2学习——@ApiImplicitParams注解
    Spring Validation 校验
    SpringBoot:通过多个Context限制Bean的活动范围
  • 原文地址:https://www.cnblogs.com/luocixin/p/6896052.html
Copyright © 2011-2022 走看看