zoukankan      html  css  js  c++  java
  • Amdroid 对话框的世界

      对话框,在手机中都是常见的。有二次操作的对话框,也有直接弹出一个利用线程结束的对话框。

    所以,这里就把自己喜欢且常用的几种对话框记录下来,随时需要,随时来取。

    很抱歉,这里木有截图:(这种对话框就属于自动式的,其实就是在里面new了一个耗时的线程而已,这样,就能制造出自动式的对话框。。。哈哈,是不是有点上色。。。)

    public void dialogToShow() {
            final ProgressDialog mProgress;
            mProgress = ProgressDialog.show(UserLoginActivity.this, "您好:" + getName
                    + "账户", "正在为您跳转到个人中心页面。。。。。");
    
            new Thread() {
                public void run() {
                    try {
                        sleep(3000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } finally {
                        mProgress.dismiss();
                        Intent intent_su = new Intent().setClass(
                                UserLoginActivity.this, UserMainActivity.class);
                        startActivity(intent_su);
    
                    }
                }
            }.start();

    然后还有需要点击的,其实在做对话框的时候,我曾遇到过一个问题,那就是对话框的点击事件会与activity里面本来继承的点击事件会有冲突,所以,会有那么一个是继承的接口,另外一个需要的是view的,所以,注意。。。。

        public void dialogToShow() {
            final AlertDialog mProgress = new AlertDialog.Builder(
                    UserRegisterGetCodeActivity.this).create();
            mProgress.show();
            mProgress.getWindow().setContentView(R.layout.success_dialog);
            RelativeLayout mLayout;
            mLayout = (RelativeLayout) mProgress.findViewById(R.id.dialog);
            mLayout.setBackground(BaseActivity.bg_Bd);
            new Thread() {
                public void run() {
                    try {
                        sleep(4000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } finally {
    
                        Intent intent = new Intent().setClass(
                                UserRegisterGetCodeActivity.this,
                                UserInfoActivity.class);
                        startActivity(intent);
                        mProgress.dismiss();
                    }
                }
            }.start();

    当然,作为喜欢自定义的我们肯定希望导入自己喜欢的布局。。。so  here you are:(其实这里用了自定义的进度条)

        public void dialogToShow() {
            final AlertDialog mProgress = new AlertDialog.Builder(
                    UserRegisterGetCodeActivity.this).create();
            mProgress.show();
            mProgress.getWindow().setContentView(R.layout.success_dialog);
            RelativeLayout mLayout;
            mLayout = (RelativeLayout) mProgress.findViewById(R.id.dialog);
            mLayout.setBackground(BaseActivity.bg_Bd);
            new Thread() {
                public void run() {
                    try {
                        sleep(4000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    } finally {
    
                        Intent intent = new Intent().setClass(
                                UserRegisterGetCodeActivity.this,
                                UserInfoActivity.class);
                        startActivity(intent);
                        mProgress.dismiss();
                    }
                }
            }.start();

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/dialog"
        android:layout_width="1280dip"
        android:layout_height="700dip" >
    
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:layout_centerInParent="true"
            android:orientation="vertical" >
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="30dip"
                android:layout_marginTop="200dip"
                android:text="       恭喜您,已经成功注册夏普账号!"
                android:textColor="#fff"
                android:textSize="35dip" />
    
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text=" 接下来为您跳转到用户信息页,您可以在这里补充详细信息!"
                android:textColor="#ddd"
                android:textSize="25dip" />
    
            <ProgressBar
                android:id="@+id/loadProgressBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="300dip"
                android:layout_marginTop="20dip"
                android:indeterminateDrawable="@drawable/color_progressbar" />
        </LinearLayout>
    
    </RelativeLayout>

    上面布局,其实最重要的一点事peogress里面的

     android:indeterminateDrawable="@drawable/color_progressbar"

    这一句,这是一个设置好看的进度条的哦:

    <?xml version="1.0" encoding="utf-8"?>
    <rotate xmlns:android="http://schemas.android.com/apk/res/android"
        android:fromDegrees="0"
        android:pivotX="50%"
        android:pivotY="50%"
        android:toDegrees="360" >
    
        <shape
            android:innerRadiusRatio="3"
            android:shape="ring"
            android:thicknessRatio="8"
            android:useLevel="false" >
            <gradient
                android:centerColor="#FFFFFF"
                android:centerY="0.50"
                android:endColor="#00f"
                android:startColor="#000"
                android:type="sweep"
                android:useLevel="false" />
        </shape>
    
    </rotate>

    嘿嘿,简单一点咯,凑合哦!

    在同时,我这里卸了一个listview的布局,类似上下文菜单的:

    public void dialogToBank() {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.create();
            LayoutInflater inflater = getLayoutInflater();
            View layout = inflater.inflate(R.layout.bank_dialog, null);
            builder.setTitle("绑定银行");
            builder.setView(layout);
            ListView mlist = (ListView) layout.findViewById(R.id.bank_list);
            // RelativeLayout mLayout = (RelativeLayout) layout
            // .findViewById(R.id.dialog);
            // mLayout.setBackground(BaseActivity.bg_Bd);
            // to get the listview
            final String[] bankStr = { "中国银行", "招商银行", "工商银行", "北京银行", "邮政银行" };
            int[] imgStr = { R.drawable.qq_ico_light, R.drawable.qq_ico_light,
                    R.drawable.qq_ico_light, R.drawable.qq_ico_light,
                    R.drawable.qq_ico_light };
            BankListAdapter adapter = new BankListAdapter(this, bankStr, imgStr);
            mlist.setAdapter(adapter);
            mlist.setOnItemClickListener(new OnItemClickListener() {
    
                @Override
                public void onItemClick(AdapterView<?> adapter, View v,
                        int position, long id) {
                    Toast.makeText(UserInfoActivity.this, bankStr[position],
                            Toast.LENGTH_SHORT).show();
                    bind_Bank.setText("已绑定" + bankStr[position]);
    
                }
            });
            builder.show();
    一切只是为了充实自己!!stay hungry and stay foolish!!
  • 相关阅读:
    HDFS源码分析(六)-----租约
    YARN源码分析(一)-----ApplicationMaster
    YARN源码分析(一)-----ApplicationMaster
    YARN源码分析(一)-----ApplicationMaster
    YARN源码分析(二)-----ResourceManager中的NM节点管理
    YARN源码分析(二)-----ResourceManager中的NM节点管理
    Confluence 6 如何备份和恢复
    Confluence 6 那些文件需要备份
    Confluence 6 确定一个生产系统备份方案
    Confluence 6 生产环境备份策略
  • 原文地址:https://www.cnblogs.com/Catherine-Brain/p/3783420.html
Copyright © 2011-2022 走看看