韩国三级高清手机在线版-韩国三级电影久久-韩国三级hd中文字幕一男多女-韩国三级hd中文字幕久久精品-日本精品在线视频-日本精品在线观看视频

 

Android關(guān)于自定義的dialog

(2013-01-15 16:34:34)

轉(zhuǎn)載

 

 

 

標(biāo)簽:

it

 

 

 

 首先在布局中寫出你自己想要的dialog的樣式Android關(guān)于自定義的dialog

由于我的圖片需要平鋪            android:layout_width="wrap_content"
           android:layout_height="wrap_content"
           android:background="@drawable/note_top"
           android:orientation="horizontal" >
       ,自己寫了一個平鋪的方法。所以在布局中看到的樣子反而不正常。在手機(jī)上能正常顯示。

 實現(xiàn)平鋪的方法很簡單
 public static void fixBackgroundRepeatY(View view) {   
       Drawable bg = view.getBackground();  
       if (bg != null) {        
              if (bg instanceof BitmapDrawable) {           
                BitmapDrawable bmp = (BitmapDrawable) bg;          
                bmp.mutate(); // make sure that we aren't sharing state anymore
                bmp.setTileModeXY(null,TileMode.REPEAT);       
               
      }
}

 

 接下來就開始寫java代碼了,第一步肯定是extends Dialog

直接貼代碼

public class HPDialog extends Dialog {

 // 先調(diào)用構(gòu)造方法在調(diào)用oncreate方法

 private static boolean isShow = true;
 private Context context;
 private String mYtitle;
 private String mYmsg;

 // private MyDialog myDialog;

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  // TODO Auto-generated method stub
  super.onCreate(savedInstanceState);
 }

 public HPDialog() {

  super(ClientEngine.getInstance().getBaseActivity());
  this.context = ClientEngine.getInstance().getBaseActivity();
 }

 public HPDialog(Context context, int theme) {
  super(context, theme);
  this.context = context;
 }

 public void setTitle(String title) {
  this.mYtitle = title;
 }

 public void setMsg(String msg) {
  this.mYmsg = msg;
 }
 @Override
 public void show() {
  super.show();
 }
 public static class Builder {

  private Context context;
  private String title;
  private String message;
  private String positiveButtonText;
  private String negativeButtonText;
  private View contentView;
  private DialogInterface.OnClickListener positiveButtonClickListener,
    negativeButtonClickListener;

  // private TextView msg=(TextView)findViewById(R.id.message);
  public Builder(Context context) {
   this.context = context;
  }

  public Builder setMessage(String message) {
   this.message = message;
   return this;
  }

  public Builder setMessage(int message) {
   this.message = (String) context.getText(message);
   return this;
  }

  public Builder setTitle(int title) {
   this.title = (String) context.getText(title);
   return this;
  }

  public Builder setTitle(String title) {
   this.title = title;
   return this;
  }

  public Builder setContentView(View v) {
   this.contentView = v;
   return this;
  }
  
  public Builder setPositiveButton(int positiveButtonText,
    DialogInterface.OnClickListener listener) {
   this.positiveButtonText = (String) context
     .getText(positiveButtonText);
   this.positiveButtonClickListener = listener;
   return this;
  }

  public Builder setPositiveButton(String positiveButtonText,
    DialogInterface.OnClickListener listener) {
   this.positiveButtonText = positiveButtonText;
   this.positiveButtonClickListener = listener;
   return this;
  }
  
  
  public boolean setCancelable(boolean cancelable){
   
   isShow = cancelable;
   return isShow;
  }

  public Builder setNegativeButton(int negativeButtonText,
    DialogInterface.OnClickListener listener) {
   this.negativeButtonText = (String) context
     .getText(negativeButtonText);
   this.negativeButtonClickListener = listener;
   return this;
  }
  
  public Builder setClickFunction(final Command[] commands) {
   if(commands != null)
   {
    if(commands[0]==null){
     this.setPositiveButton("知道了", new OnClickListener() {
      
      @Override
      public void onClick(DialogInterface dialog,
        int which) {

      }
     });
    }else{
     this.setPositiveButton(commands[0].getLabel(), new OnClickListener() {
      
      @Override
      public void onClick(DialogInterface dialog,
        int which) {
       commands[0].onClick();
      }
     });
    }
    if(commands[1]!=null){
     this.setNegativeButton(commands[1].getLabel(), new OnClickListener() {
      
      @Override
      public void onClick(DialogInterface dialog,
        int which) {
       commands[1].onClick();
      }
     });
    }
   }
   return this;
  }

  public Builder setNegativeButton(String negativeButtonText,
    DialogInterface.OnClickListener listener) {
   this.negativeButtonText = negativeButtonText;
   this.negativeButtonClickListener = listener;
   return this;
  }

  public HPDialog show() {
   HPDialog dialog = create();
   dialog.show();
   return dialog;
  }
  
  public HPDialog create() {
   LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
   
   // instantiate the dialog with the custom Theme
   final HPDialog dialog = new HPDialog(context, R.style.HPDialog);
   dialog.setCanceledOnTouchOutside(false);//android 4.0以上dialog點擊其他地方也會消失false以后就只能點擊按鈕消失
   
   View layout = inflater.inflate(R.layout.dialog, null);
   
   ScrollView sv = (ScrollView) layout.findViewById(R.id.HpDialogScrollView);
   
   int width = context.getResources().getDrawable(R.drawable.note_top).getIntrinsicWidth();
   
   
   sv.getLayoutParams().width=width-30;
   
   if(message!=null && message.length()>160){
    
    sv.getLayoutParams().height=MainMenu.screenHeight*2/5;
    
   }
   
   dialog.addContentView(layout, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
   // set the dialog title
   ((TextView)layout.findViewById(R.id.title)).setText(title);
   
   // set the confirm button
   if (positiveButtonText != null) {
    
    ((Button) layout.findViewById(R.id.dialog_button_ok)).setText(positiveButtonText);
    
    if (positiveButtonClickListener != null) {
     
     ((Button) layout.findViewById(R.id.dialog_button_ok)).setOnClickListener(new View.OnClickListener() {
      
        public void onClick(View v) {
         
         positiveButtonClickListener.onClick(dialog,DialogInterface.BUTTON_POSITIVE);
         dialog.dismiss();
        }
       });
    }
   } else {
    
    // if no confirm button just set the visibility to GONE
    layout.findViewById(R.id.dialog_button_ok).setVisibility(View.GONE);
   }
   if (negativeButtonText != null) {
    
    ((Button) layout.findViewById(R.id.dialog_button_cancel)).setText(negativeButtonText);
    if (negativeButtonClickListener != null) {
     
     
//     ((Button) layout.findViewById(R.id.dialog_button_ok)).
     
     ((Button) layout.findViewById(R.id.dialog_button_cancel)).setOnClickListener(new View.OnClickListener() {
      
        public void onClick(View v) {
         
         negativeButtonClickListener.onClick(dialog, DialogInterface.BUTTON_NEGATIVE);
         
         dialog.dismiss();
        }
       });
    }
   } else {
    
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) ((Button) layout.findViewById(R.id.dialog_button_ok)).getLayoutParams();
   
    params.setMargins(30, 0, 30, 0);//這個只是根據(jù)我自己的需要調(diào)節(jié)按鈕的位置。大家可以根據(jù)自己的需要來調(diào)節(jié)
    params.width = width-60;
    ((Button) layout.findViewById(R.id.dialog_button_ok)).setLayoutParams(params);
    
    // if no confirm button just set the visibility to GONE
    layout.findViewById(R.id.dialog_button_cancel).setVisibility(View.GONE);
   }
   
   // set the cancel button

   // set the content message
   
   if (message != null) {
    
    ((TextView) layout.findViewById(R.id.msg)).setText(message);
    
   } else if (contentView != null) {
    
    // if no message set
    // add the contentView to the dialog body
    
    ((LinearLayout) layout.findViewById(R.id.body)).removeAllViews();
    
    ((LinearLayout) layout.findViewById(R.id.body)).addView(
      contentView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
   }
   dialog.setContentView(layout);
   return dialog;
  }
 }
}

 

這樣一個自定義的dialog就搞定了。用法和系統(tǒng)的一樣。只是換了個顯示樣式

 

穩(wěn)定

產(chǎn)品高可用性高并發(fā)

貼心

項目群及時溝通

專業(yè)

產(chǎn)品經(jīng)理1v1支持

快速

MVP模式小步快跑

承諾

我們選擇聲譽

堅持

10年專注高端品質(zhì)開發(fā)
  • 返回頂部
被多男摁住灌浓精| 男人一边吃奶一边弄下边好爽| CHINESE熟女老女人HD| 亚洲精品综合欧美一区二区三区| 熟女精品视频一区二区三区 | 果冻传媒蜜桃传媒精东豆| 成人区人妻精品一区二| 24种男女插秧法| 亚洲色AV性色在线观无码| 亚洲AV成人午夜福利在线观看| 色综合久久88色综合天天| 欧美国产亚洲日韩在线二区| 久久人搡人人玩人妻精品| 娇妻被别人玩弄至高潮| 国产偷亚洲偷欧美偷精品| 公交车大龟廷进我身体里| 潮喷大喷水系列无码| YYY6080韩国三级理论| 18禁黄网站禁片免费观看国产| 荫蒂每天被男人添| 亚洲已满18点击进入在线看片| 亚洲丁香婷婷久久一区二区| 亚洲AV成人深夜一区午夜网站| 五月丁香色综合久久4438| 无码精品人妻一区二区三区AV| 婷婷五月18永久免费网站| 双乳被一左一右吃着的小说| 少妇人妻无码专区视频| 三上悠亚SSNI452内衣模特| 日本熟妇啪啪日本丰满熟妇啪啪日| 欧美日韩精品视频一区二区三区| 免费A级毛片无码免费视频首页| 久久久亚洲欧洲日产无码AV| 久久久精品波多野结衣| 久久久久国色AV免费观看| 精品一线二线三线精华液| 精品少妇人妻AV无码专区| 亚洲视频在线观看| 18禁强伦姧人妻又大又粗| 把腿张开老子臊烂你在线观看| 无码H黄肉3D动漫在线观看| 日精品一区二区蜜桃AV| 日本精品无码一区二区三区久久久| 欧美久久高潮久久高潮| 欧美大屁股流白浆XXXX视频| 欧美丰满熟妇XXXX性大屁股| 年级老师的滋味4| 欧美人妻精品一区二区免费看| 欧美V亚洲V综合Ⅴ国产V| 欧美精产国品一二三区别| 欧美VA久久久噜噜噜久久| 欧美国产SE综合| 欧洲熟妇的性久久久久久| 欧美群交XXXCOM| 人与善交XUANWEN18| 日韩VA中文字幕无码电影| 色爽黄1000部免费软件下载| 少妇无码太爽了不卡视频在线看| 少妇高潮惨叫久久久久久电影| 少妇性XXXXXXXXX色武功| 天天躁日日躁狠狠躁| 无码人妻AⅤ一区二区三区玉蒲团| 无码播放一区二区三区| 性色AV性色生活片| 亚洲成AV人片在线观看无APP| 亚洲精品成人无码中文毛片| 亚洲人妻AAA网站| 岳今晚让我玩个够肥水一体探岳| 中文字幕无线码免费人妻| CAOPORM超免费公开视频| 被强迫的爱人 电影| 东京热人妻无码人AV| 国产乱码精品一区二区三区中文| 国产又色又爽又刺激在线观看| 娇小VIDEOS出血| 老太太 GRANNY| 欧美人交A欧美精品AV一区 | 久久精品国产亚洲AV嫖农村妇女 | 人妻无码熟妇乱又伦精品| 熟女丝袜香蕉双人女高潮| 亚洲爱婷婷色婷婷五月| 野花高清视频免费观看完整版中文| 337P日本大胆欧洲色噜噜| 厨房里的激战2类型| 国产在线无码一区二区三区| 久久亚洲日韩成人无码导航| 人妻精品久久久久中文字幕69| 天美传媒MV在线播放高清视频| 亚洲国产精品无码久久久| 97人妻人人做人碰人人爽一| 俄罗斯性孕妇孕交| 精产国品一二三产品区别视频手机| 乱人伦中文无码视频在线观看| 日本无人区一线影视| 亚洲AV成人无码精品网站| 正在播放国产剧情亂倫| 大胆顶级欧美艺术图片| 精品久久无码中文字幕| 欧美黑人一级二级巨大久久天堂| 太太其实你也很想要的对吧| 亚洲人成人无码.WWW石榴| 99精品国产兔费观看久久| 国产精品成人无码免费| 里番本子侵犯肉全彩无码| 色欲AV自慰一区二区三区 | 97一期涩涩97片久久久久久久| 粉嫩小泬无遮挡久久久久久小说| 狠狠色婷婷久久一区二区三区| 欧美疯狂3p群体交乱视频丨zu| 午夜无码视频在线观看网站| 中文字日产幕码三区的做法步| 国产成人AV区一区二区三| 久久久久99精品成人片三人毛片 | 色偷偷偷久久伊人大杳蕉| 亚洲人成人网站色www小说| 成人欧美一区二区三区黑人 | 色综合色狠狠天天综合网| 亚洲色无码中文字幕手机在线| 不卡AV一区二区| 精品无码国产AV一区二区三区| 日本一区二区三区久久久久久久久| 亚洲精品无码久久毛片| 多毛丰满日本熟妇| 里番本子纯肉侵犯肉全彩无码| 无码不卡AV东京热毛片| 777ZYZ玖玖资源站最稳定网| 国产亚洲午夜高清国产拍精品| 欧洲美女粗暴牲交免费观看| 亚洲国产精品无码久久98蜜桃| 吃瓜爆料黑料不打烊| 久久婷婷综合缴情亚洲狠狠| 无码成人精品区在线观看| BDB14黑人巨大视频| 精品无人区麻豆乱码1区2| 他的粗大把她捣出白沫| 92国产精品午夜福利| 精品国产AV无码专区亚洲AV| 少妇粉嫩小泬喷水视频| 2021亚洲无码| 精品亚洲国产成人AV| 脱色摇床THERMO网站| GOGO西西自慰人体高清人体模| 久久69国产精品久久69软件| 婷婷成人五月综合激情| XXXXHDTEEN欧美内射| 久久亚洲精品成人无码| 亚洲AV无码专区国产乱码波多野 | 亚洲一区二区三区毛片| 国产精品美女一区二区三区| 琪琪午夜伦伦电影理论片| 一級黃色毛片免費看| 国精产品一二三四线免费| 少妇ⅩXXOOOZZXXHD| A级无遮挡超级高清-在线观看| 久久久久久久久久久综合日本| 亚洲AV成人网站在线播放| 粉嫩av一区二区网站入口| 欧美三级不卡在线观看| 在线观看高H无码黄动漫| 极品国产主播粉嫩在线观看| 少妇高清精品毛片在线视频| H罩杯大胸爆乳交在线观看 | 免费观看亚洲人成网站| 亚洲人成人无码www五月婷| 国产婷婷成人久久AV免费高清| 日韩人妻中文无码一区二区| 99热精国产这里只有精品| 老熟妇XXXⅩHD老熟女| 亚洲第一SE情网站| 国产午夜精品一区二区三区老| 色偷偷88888欧美精品久久久| S货叫大点声C烂你的SB| 女儿儿媳陪自己玩的心情说说| 野花社区免费观看高清在线1日本| 国色天香精品一卡2卡3卡4| 我故意没有穿内裤坐公车让| 东京热无码一区二区三区AV| 人摸人人人澡人人超碰| AV无码人妻中文字幕| 免费看撕开奶罩揉吮奶头视频 | 爆乳一区二区三区无码| 欧美疯狂做受XXXXX高潮| 18成禁人视频免费网站| 久久青榴社区福利无码| 亚洲色偷偷综合亚洲AV伊人| 精品国产你懂的在线观看| 亚洲AV无码专区亚洲AV桃| 国产手机在线国内精品| 午夜亚洲WWW湿好爽| 国产精品无码素人福利| 凸凹人妻人人澡人人添医| 国产成人无码免费视频在线| 熟妇高潮一区二区精品de| 国产9 9在线 | 中文| 少妇高潮惨叫喷水正在播放 | 国产精品久久久久久久影院 | 永久免费AV网站可以直接看的| 久久午夜夜伦鲁鲁片免费无码影院| 伊人久久大香线蕉AV色| 蜜臀AV无码一区二区三区小说|