欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

android中定制的dialog

系統(tǒng) 2277 0

?

    public ShelfSwitchDialog(Context context) {
		super(context,android.R.style.Theme_NoTitleBar);
		setContentView(R.layout.newspaper_switch_dialog);
		this.context = context;
		Window win = getWindow();
		win.getAttributes().gravity = Gravity.TOP;
		win.setBackgroundDrawableResource(R.drawable.newspaper_blank);
		//大小
		win.setLayout(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	}
  

? ? dialog的定制 :

? ? public class ShelfSwitchDialog extends Dialog implements OnClickListener{

    	Context context;
	ImageView yingyong,shudian,baojia;
	int selectIndex;
	String[] choiceItems = new String[]{"圖書","報架"};
	
	public ShelfSwitchDialog(Context context,int paddingLeft){
		this(context);
		View v = findViewById(R.id.dialog_root_layout);
		v.setPadding(paddingLeft-50,50,v.getPaddingRight(),v.getPaddingBottom());
		yingyong = (ImageView)findViewById(R.id.yingyong);
		yingyong.setOnClickListener(this);
		shudian = (ImageView)findViewById(R.id.shudian);
		shudian.setOnClickListener(this);
		baojia = (ImageView)findViewById(R.id.baojia);
		baojia.setOnClickListener(this);
	}
	
	public ShelfSwitchDialog(Context context) {
		super(context,android.R.style.Theme_NoTitleBar);
		setContentView(R.layout.newspaper_switch_dialog);
		this.context = context;
		Window win = getWindow();
		win.getAttributes().gravity = Gravity.TOP;
		win.setBackgroundDrawableResource(R.drawable.newspaper_blank);
		//大小
		win.setLayout(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
	}
	public AlertDialog create(){
		if(context==null){return null;}
		final boolean instOfStore = context instanceof ShelfActivity||context instanceof BooksListActivity;
		final boolean instOfShelf = context instanceof NewspaperShelf;
		final Intent shelfIntent = new Intent(context,NewspaperShelf.class);
		final Intent storeIntent = new Intent(context,ShelfActivity.class);
		AlertDialog.Builder builder = new AlertDialog.Builder(context);
		AlertDialog dialog =  builder
        .setIcon(R.drawable.newspaper_ic_switch)
        .setTitle("切換到:")
        .setSingleChoiceItems(choiceItems, 0, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
            	selectIndex =  whichButton;
            }
        })
        .setPositiveButton("確定", new DialogInterface.OnClickListener() {
        	
            public void onClick(DialogInterface dialog, int whichButton) {
//            	Log.v("","whichButton:"+selectIndex);
            	if(instOfStore){
            		switch(selectIndex){
            		case 0:
            			Toast.makeText(context,"當(dāng)前已是書店",Toast.LENGTH_SHORT).show();
            			break;
            		case 1:
            			context.startActivity(shelfIntent);
            			break;
            		}
            	}
            	else if(instOfShelf){
            		switch(selectIndex){
            		case 0:
            			((ShelfActivity)context).finish();
            			break;
            		case 1:
            			Toast.makeText(context,"當(dāng)前已是報架",Toast.LENGTH_SHORT).show();
            			break;
            		}
            	}
            }
        })
        .setNegativeButton("取消", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
            	
            }
        })
       .create();
		dialog.getWindow().getAttributes().gravity = Gravity.TOP;
		dialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
		return dialog;
	}

	@Override
	public void onClick(View v) {
		final boolean instOfShelf = context instanceof ShelfActivity;
		final boolean instOfNewspaperShelf = context instanceof NewspaperShelf;
		final boolean instOfStoreActivity = context instanceof StoreActivity;
		final boolean instOfBooksListActivity = context instanceof BooksListActivity;
		final Intent newspaperShelfIntent = new Intent(context,NewspaperShelf.class);
		final Intent shelfIntent = new Intent(context,ShelfActivity.class);
		switch(v.getId()){
		case R.id.yingyong:
			Intent intent = new Intent("cn.chutong.ereader.finishactivity");
			dismiss();
			context.sendBroadcast(intent);
			break;
		case R.id.shudian:
			if(instOfNewspaperShelf){
				((NewspaperShelf)context).finish();
				dismiss();
			}
			else if(instOfShelf||instOfBooksListActivity){
				Toast.makeText(context,"當(dāng)前已是書店",Toast.LENGTH_SHORT).show();
				dismiss();
			}
			else if(instOfStoreActivity){
				dismiss();
				((StoreActivity)context).finish();
				context.startActivity(shelfIntent);
			}
			break;
		case R.id.baojia:
			if(instOfNewspaperShelf){
				Toast.makeText(context,"當(dāng)前已是報架",Toast.LENGTH_SHORT).show();
				dismiss();
			}
			else if(instOfShelf||instOfBooksListActivity){
				context.startActivity(newspaperShelfIntent);
				dismiss();
			}
			else if(instOfStoreActivity){
				context.startActivity(newspaperShelfIntent);
				dismiss();
				((StoreActivity)context).finish();
			}
			break;
		
		}
	}
}
  
?

? ?效果圖:

?

?


android中定制的dialog

?

?

第二種情況:

?

    addCustomDlg = new Dialog(this, R.style.dialog);
addCustomDlg.setContentView(R.layout.add);
addCustomDlg.show();
confirmBtn = (Button) addCustomDlg.findViewById(R.id.confirmBtn);
edit = (EditText) addCustomDlg.findViewById(R.id.txt);
edit.setText("");
btn_back = (ImageButton) addCustomDlg.findViewById(R.id.btn_back);
btn_back.setOnClickListener(this);
confirmBtn.setOnClickListener(this);
  

? ?直接從dialog中獲取控件,并綁定事件

? 效果:


android中定制的dialog

android中定制的dialog


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 国产在线a | 一区二区三区回区在观看免费视频 | 国产高清永久免费 | 欧美性色生活片免费播放 | 香港一级毛片免费看 | 久久涩涩 | 久久久精彩视频 | 国产欧美在线视频 | 国产成人综合AV在线观看不止 | 激情一区二区三区成人 | 天天怕夜夜怕狠狠怕 | 高清国产一区二区三区四区五区 | 好叼操 | 久久观看午夜精品 | 奇米影视第四色7777 | 欧美精品一区二区三区蜜桃视频 | 亚洲第一男人天堂 | 日韩中文字幕一区 | 男生插女生视频免费 | 久久精品一区二区三区不卡牛牛 | 黄色在线观看 | 天天插天天操天天干 | 亚洲午夜av | 欧美黑人又粗又长 | 在线观看国产 | 国产亚洲精彩视频 | 亚洲精品国产电影 | 久久免费看 | 亚洲欧美日韩综合一区久久 | 国产在线综合网 | 欧美午夜影院 | 国产午夜精品一区二区三区 | 99re6热只有精品免费观看 | 五月婷婷丁香 | 欧美一级大片免费观看 | 欧美中文字幕一区二区 | 五月缴情| 免费又粗又硬进去好爽A片视频 | 热er99久久6国产精品免费 | 99精品视频在线在线视频观看 | 国产激情在线观看 |