The android implementation is similar to the iphone dialog box style.
Continued: it seems that there is a big gap between brother Tao and brother FA for Android Development in Shanghai ke Xuan. I summarized the technology of xiafao and used it for installation and use.
See here: http://blog.csdn.net/xiechengfa/article/details/40373331
package com.zf.iosdialog;import java.util.ArrayList;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.Toast;import com.zf.iosdialog.bean.SheetItem;import com.zf.iosdialog.widget.IosDialog;public class MainActivity extends Activity implements OnClickListener, OnSheetMyItemClickListner {private Button btn1;private Button btn2;private Button btn3;private Button btn4;private Button btn5;/*** * weixinNumber: lixiaodaoaaa weibo:www.weibo.com/lixiaodaoaaa thanks * :xiechengfa */@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initView();}private void initView() {btn1 = (Button) findViewById(R.id.btn1);btn1.setOnClickListener(this);btn2 = (Button) findViewById(R.id.btn2);btn2.setOnClickListener(this);btn3 = (Button) findViewById(R.id.btn3);btn3.setOnClickListener(this);btn4 = (Button) findViewById(R.id.btn4);btn4.setOnClickListener(this);btn5 = (Button) findViewById(R.id.btn5);btn5.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {case R.id.btn5 :IosDialog iosDialog = new IosDialog(MainActivity.this);ArrayList
listSheetItems = new ArrayList
();listSheetItems.add(new SheetItem("shabi001", 1));listSheetItems.add(new SheetItem("shabi002", 2));listSheetItems.add(new SheetItem("shabi003", 3));listSheetItems.add(new SheetItem("shabi004", 4));listSheetItems.add(new SheetItem("shabi005", 5));listSheetItems.add(new SheetItem("shabi006", 6));iosDialog.setSheetItems(listSheetItems, MainActivity.this);iosDialog.show();break;default :break;}}@Overridepublic void onClickItem(int which) {switch (which) {case 1 :Toast.makeText(this, "lixiaodaoaaa001", Toast.LENGTH_SHORT).show();break;case 2 :Toast.makeText(this, "lixiaodaoaaa002", Toast.LENGTH_SHORT).show();break;case 3 :Toast.makeText(this, "lixiaodaoaaa003", Toast.LENGTH_SHORT).show();break;case 4 :Toast.makeText(this, "lixiaodaoaaa004", Toast.LENGTH_SHORT).show();break;case 5 :Toast.makeText(this, "lixiaodaoaaa005", Toast.LENGTH_SHORT).show();break;case 6 :Toast.makeText(this, "lixiaodaoaaa006", Toast.LENGTH_SHORT).show();break;default :break;}}}
IOSDialog code (to prevent this effect)
Package com. zf. iosdialog. widget; import java. util. list; import android. app. dialog; import android. content. context; import android. graphics. color; import android. view. display; import android. view. gravity; import android. view. layoutInflater; import android. view. view; import android. view. view. onClickListener; import android. view. window; import android. view. windowManager; import android. widget. linearLayout; import android. widget. linearLayout. layoutParams; import android. widget. scrollView; import android. widget. textView; import com. zf. iosdialog. onSheetMyItemClickListner; import com. zf. iosdialog. r; import com. zf. iosdialog. bean. sheetItem; public class IosDialog {private Context context; private Dialog dialog; private TextView txt_title; private TextView txt_cancel; private LinearLayout lLayout_content; private ScrollView sLayout_content; private boolean showTitle = false; private List
ListSheetItems; private Display display; public IosDialog (Context context) {this. context = context; WindowManager windowManager = (WindowManager) context. getSystemService (Context. WINDOW_SERVICE); display = windowManager. getdefadisplay display (); builder ();} public IosDialog builder () {// obtain the Dialog Layout View = LayoutInflater. from (context ). inflate (R. layout. view_actionsheet, null); // sets the minimum width of the Dialog to the screen width. setMinimumWidth (display. getWidth (); // obtain the sLayout_content = (ScrollView) view in the Custom Dialog layout. findViewById (R. id. sLayout_content); lLayout_content = (LinearLayout) view. findViewById (R. id. lLayout_content); txt_title = (TextView) response _ title); txt_cancel = (TextView) response _ cancel); txt_cancel.setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {dialog. dismiss () ;}}); // defines the Dialog layout and parameter dialog = new Dialog (context, R. style. actionSheetDialogStyle); dialog. setContentView (view); Window dialogWindow = dialog. getWindow (); dialogWindow. setGravity (Gravity. LEFT | Gravity. BOTTOM); WindowManager. layoutParams lp = dialogWindow. getAttributes (); lp. x = 0; lp. y = 0; dialogWindow. setAttributes (lp); return this;} public IosDialog setTitle (String title) {showTitle = true; txt_title.setVisibility (View. VISIBLE); txt_title.setText (title); return this;} public IosDialog setCancelable (boolean cancel) {dialog. setCancelable (cancel); return this;} public IosDialog setCanceledOnTouchOutside (boolean cancel) {dialog. setCanceledOnTouchOutside (cancel); return this;}/** set the Entry Layout */public void setSheetItems (List
SheetItemList, final OnSheetMyItemClickListner itemLisenner) {this. listSheetItems = sheetItemList; if (sheetItemList = null | sheetItemList. size () <= 0) {return;} int size = sheetItemList. size (); // TODO height control, unoptimal solution // if (size> = 7) {LinearLayout when too many entries are added. layoutParams params = (LayoutParams) sLayout_content.getLayoutParams (); params. height = display. getHeight ()/2; sLayout_content.setLayoutParams (params);} // Add entries for (int I = 1; I <= size; I ++) {final int index = I; final SheetItem sheetItem = sheetItemList. get (I-1); String strItem = sheetItem. getStrItemName (); TextView textView = new TextView (context); textView. setText (strItem); textView. setTextSize (18); textView. setGravity (Gravity. CENTER); // background image if (size = 1) {if (showTitle) {textView. setBackgroundResource (R. drawable. actionsheet_bottom_selector);} else {textView. setBackgroundResource (R. drawable. actionsheet_single_selector) ;}} else {if (showTitle) {if (I >=1 & I <size) {textView. setBackgroundResource (R. drawable. actionsheet_middle_selector);} else {textView. setBackgroundResource (R. drawable. actionsheet_bottom_selector);} else {if (I = 1) {textView. setBackgroundResource (R. drawable. actionsheet_top_selector);} else if (I <size) {textView. setBackgroundResource (R. drawable. actionsheet_middle_selector);} else {textView. setBackgroundResource (R. drawable. actionsheet_bottom_selector) ;}} textView. setTextColor (Color. parseColor (SheetItemColor. blue. getName (); // float scale = context. getResources (). getDisplayMetrics (). density; int height = (int) (45 * scale + 0.5f); textView. setLayoutParams (new LinearLayout. layoutParams (LayoutParams. MATCH_PARENT, height); // click the event textView. setOnClickListener (new OnClickListener () {@ Overridepublic void onClick (View v) {itemLisenner. onClickItem (sheetItem. getITEM_CODE (); dialog. dismiss () ;}}); lLayout_content.addView (textView) ;}} public void show () {dialog. show ();} public interface OnSheetItemClickListener {void onClick (int which);} public enum SheetItemColor {Blue ("# 037BFF"), Red ("# FD4A2E "); private String name; private SheetItemColor (String name) {this. name = name;} public String getName () {return name;} public void setName (String name) {this. name = name ;}}}
This demo1:
Click here to break it down. I lose money. ^_^
Brother Tao finishing address 2
: Click here, and I will lose money if it breaks down.
Zookeeper