zoukankan      html  css  js  c++  java
  • android人人网登陆例子研究

    eoe上有源码,点击一个自定义图片按钮控件,弹出自定义的一个dialog..内含输入框可登陆.
    自定的图片按钮:ConnectButton.java
    对话框:RenrenDialog.java
     
    传值
    Bundle bundle=new Bundle();bundle.putString("store", "数据来自Activity1");Intent mIntent=new Intent();
    mIntent.putExtras(bundle);
    获取
    Bundle extras=getIntent().getExtras();
    if(extras!=null){data=extras.getString("store");}
     
    Dialog
    //根据不同事件弹出不同的窗口
    //showDialog(dialog)时调用这里
    @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG1: return buildDialog1(ActivityMain.this); case DIALOG2: return buildDialog2(ActivityMain.this); case DIALOG3: return buildDialog3(ActivityMain.this); case DIALOG4: return buildDialog4(ActivityMain.this); } return null; }
    protected void onPrepareDialog(int id, Dialog dialog){ if(id==DIALOG1){ setTitle("测试"); }
    //这里很奇怪,好像是窗口打开时运行的东西,判断某个为dialog1时改变标题(嗯,)
    } Button button1 = (Button) findViewById(R.id.button1); button1.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(DIALOG1); } }); Button buttons2 = (Button) findViewById(R.id.buttons2); buttons2.setOnClickListener(new OnClickListener() { public void onClick(View v) { showDialog(DIALOG2); } }); //。。其他button private Dialog buildDialog1(Context context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setIcon(R.drawable.alert_dialog_icon); builder.setTitle(R.string.alert_dialog_two_buttons_title); builder.setPositiveButton(R.string.alert_dialog_ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setTitle("点击了对话框上的确定按钮"); } }); builder.setNegativeButton(R.string.alert_dialog_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setTitle("点击了对话框上的取消按钮"); } }); return builder.create(); }//弹出窗口信息

    private Dialog buildDialog3(Context context) {
      LayoutInflater inflater = LayoutInflater.from(this);
      final View textEntryView = inflater.inflate(//在dialog内放入实例化的view,定义所需的内容,如登录信息等
        R.layout.alert_dialog_text_entry, null);
      AlertDialog.Builder builder = new AlertDialog.Builder(context);
      builder.setIcon(R.drawable.alert_dialog_icon);
      builder.setTitle(R.string.alert_dialog_text_entry);
      builder.setView(textEntryView);
      builder.setPositiveButton(R.string.alert_dialog_ok,
        new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int whichButton) {
          setTitle("点击了对话框上的确定按钮");
         }
        });
      builder.setNegativeButton(R.string.alert_dialog_cancel,
        new DialogInterface.OnClickListener() {
         public void onClick(DialogInterface dialog, int whichButton) {
          setTitle("点击了对话框上的取消按钮");
         }
        });
      return builder.create();
     }

     private Dialog buildDialog4(Context context) {
      ProgressDialog dialog = new ProgressDialog(context);//Loading 之前都是alertDialog,这里是ProgressDialog
      dialog.setTitle("正在下载歌曲");
      dialog.setMessage("请稍候……");
      return  dialog;
     }

     
    待续
  • 相关阅读:
    java学习--基础知识进阶第十四天--xml文件的概述与应用场景、xml文件的组成部分&如何编写xml、xml的两种解析方式的原理、Dom4J开源工具的使用
    java学习--基础知识进阶第十三天--笔记
    java学习--基础知识进阶第十三天--反射机制的概述和字节码对象的获取方式、反射操作构造方法、成员方法、成员属性、JavaBean的概述&BeanUtils的使用、自定义BeanUtils工具类
    java学习--基础知识进阶第十二天--笔记
    java学习--基础知识进阶第十二天--网络编程概述、UDP协议、TCP协议
    java学习--基础知识进阶第十一天--多线程概述、线程实现、多线程安全问题产生 & 解决方案
    杭电oj 1000
    建立消息映射和消息处理
    c程序设计语言 导言
    句柄数不停增加
  • 原文地址:https://www.cnblogs.com/zwl12549/p/2020289.html
Copyright © 2011-2022 走看看