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;
     }

     
    待续
  • 相关阅读:
    doges
    Unity Fps示例
    使用Unity的2D功能开发弹球游戏
    Unity UGUI 原理篇(二):Canvas Scaler 縮放核心
    UGUI 深度優化提升手遊效能
    关于Unity中的UGUI优化,你可能遇到这些问题
    git branch --set-upstream 本地关联远程分支
    git rm 与 git reset
    Git笔记之初识vi编辑器
    [内容分享]粗略判断Shader每条代码的成本
  • 原文地址:https://www.cnblogs.com/zwl12549/p/2020289.html
Copyright © 2011-2022 走看看