Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use MMAlert in Wechat

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Wechat how to use MMAlert, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

If you have often used Wechat or iphone, you will find a translucent menu that pops up from the bottom. The menu style is beautiful and the user experience is good. Take a look at the effect first.

MMAlert comes from the sdk example on the open platform of Wechat, and the code of the example is a bit messy. I deleted and arranged it, and only retained part of the functions of MMAlert, that is, the function that achieves the above effect. Because the other functions are relatively simple, that is, ordinary AlertDialog, I think everyone understands it, so I deleted it directly.

Code introduction

1. The following code is actually quite easy to understand, the essence is new a dialog box, and then put it at the bottom, for it to set up theme and style,theme and style to write very easy to understand, you can see the source code. Listview is used to render the data, so we need to new a BaseAdapter object to manage the data. BaseAdapter has nothing special and is easy to understand. Please see the code for details.

/ * @ param context * Context. * @ param title * The title of this AlertDialog can be null. * @ param items * button name list. * @ param alertDo * methods call Id:Button + cancel_Button. * @ param exit * Name can be null.It will be Red Color * @ return An AlertDialog * / public static Dialog showAlert (final Context context, final String title, final String [] items, String exit, final OnAlertSelectId alertDo, OnCancelListener cancelListener) {String cancel = context.getString (R.string.app_cancel) Final Dialog dlg = new Dialog (context, R.style.MMTheme_DataSheet); LayoutInflater inflater = (LayoutInflater) context.getSystemService (Context.LAYOUT_INFLATER_SERVICE); LinearLayout layout = (LinearLayout) inflater.inflate (R.layout.alert_dialog_menu_layout, null); final int cFullFillWidth = 10000; layout.setMinimumWidth (cFullFillWidth) Final ListView list = (ListView) layout.findViewById (R.id.content_list); AlertAdapter adapter = new AlertAdapter (context, title, items, exit, cancel); list.setAdapter (adapter); list.setDividerHeight (0) List.setOnItemClickListener (new OnItemClickListener () {@ Override public void onItemClick (AdapterView parent, View view, int position) Long id) {if (! (title = = null | | title.equals (")) & & position-1 > = 0) {alertDo.onClick (position-1) Dlg.dismiss (); list.requestFocus ();} else {alertDo.onClick (position) Dlg.dismiss (); list.requestFocus ();}); / / set a large value put it in bottom Window w = dlg.getWindow () WindowManager.LayoutParams lp = w.getAttributes (); lp.x = 0; final int cMakeBottom =-1000; lp.y = cMakeBottom; lp.gravity = Gravity.BOTTOM; dlg.onWindowAttributesChanged (lp); dlg.setCanceledOnTouchOutside (true) If (cancelListener! = null) dlg.setOnCancelListener (cancelListener); dlg.setContentView (layout); dlg.show (); return dlg;}

two。 How to use MMAlert? It's simple!

FindViewById (R.id.send_img) .setOnClickListener (new View.OnClickListener () {@ Override public void onClick (View v) {MMAlert.showAlert (SendToWXActivity.this, getString (R.string.send_img), SendToWXActivity.this.getResources () .getStringArray (R.array.send_img_item), null) New MMAlert.OnAlertSelectId () {@ Override public void onClick (int whichButton) {switch (whichButton) {case MMAlertSelect1: {break } case MMAlertSelect2: {break;} case MMAlertSelect3: {break } default: break;}})

Code download

Http://download.csdn.net/detail/singwhatiwanna/5338394

Or http://www.kuaipan.cn/file/id_105515054266321788.htm.

After reading the above, have you mastered how to use MMAlert in Wechat? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report