模擬QQ側滑控制項 實現三種界面切換效果(知識點:回調機制,解析網路json數據,fragment用法等)。

来源:http://www.cnblogs.com/labixiaoxin/archive/2016/01/07/5110759.html
-Advertisement-
Play Games

需要用到的lib包 :解析json gson包,從網路地址解析json數據成String字元串的非同步網路解析工具AsyncHttpClient等下載地址:點擊下載Xlistview 下拉上拉第三方框架 點擊下載側滑菜單的lib 點擊下載 1 package com.lixu.testjsonall;...


需要用到的lib包 :解析json  gson包,從網路地址解析json數據成String字元串的非同步網路解析工具AsyncHttpClient等

下載地址:點擊下載

Xlistview 下拉上拉第三方框架  點擊下載  

 側滑菜單的lib  點擊下載

 1 package com.lixu.testjsonall;
 2 
 3 import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
 4 import com.jeremyfeinstein.slidingmenu.lib.app.SlidingActivity;
 5 import com.lixu.testjsonall.fragments.Cehua_Fragment;
 6 import com.lixu.testjsonall.fragments.Fragment_one;
 7 import com.lixu.testjsonall.fragments.Fragment_tiyuxinwen;
 8 import com.lixu.testjsonall.fragments.Fragment_yulexinwen;
 9 import android.os.Bundle;
10 import android.view.Window;
11 
12 // 實現三個Fragment的介面類來實現回調
13 public class MainActivity extends SlidingActivity implements Cehua_Fragment.SetonCehuaFragmentClickListener,
14         Fragment_one.SetonFragmentOneClickListener, Fragment_tiyuxinwen.SetonFragmentTiyuxinwenClickListener,
15         Fragment_yulexinwen.SetonFragmentYulexinwenClickListener {
16 
17     @Override
18     public void onCreate(Bundle savedInstanceState) {
19         super.onCreate(savedInstanceState);
20         requestWindowFeature(Window.FEATURE_NO_TITLE);
21         setContentView(R.layout.activity_main);
22 
23         getFragmentManager().beginTransaction().add(R.id.main_framelayout, Fragment_one.newFragment()).commit();
24         // 設置滑出菜單為demo中轉樣式
25         setBehindContentView(R.layout.demo);
26         // 將中轉demo佈局替換為自定義滑出菜單樣式
27         getFragmentManager().beginTransaction().add(R.id.demo, Cehua_Fragment.newFragment()).commit();
28         // 獲取菜單滑出菜單實例
29         SlidingMenu slidingMenu = getSlidingMenu();
30         // 設置滑出菜單的停止寬度
31         slidingMenu.setBehindOffsetRes(R.dimen.weight);
32 
33     }
34 
35     @Override
36     public void loadxinwen() {
37         getFragmentManager().beginTransaction().replace(R.id.main_framelayout, Fragment_one.newFragment()).commit();
38         // 添加界面後關閉側滑按鈕框
39         toggle();
40     }
41 
42     @Override
43     public void loadyulexinwen() {
44         getFragmentManager().beginTransaction().replace(R.id.main_framelayout, Fragment_yulexinwen.newFragment())
45                 .commit();
46         toggle();
47     }
48 
49     @Override
50     public void loadtiyuxinwen() {
51         getFragmentManager().beginTransaction().replace(R.id.main_framelayout, Fragment_tiyuxinwen.newFragment())
52                 .commit();
53         toggle();
54     }
55 
56     @Override
57     public void back() {
58         toggle();
59 
60     }
61 
62 }
 1 package com.lixu.testjsonall.fragments;
 2 
 3 import com.lixu.testjsonall.R;
 4 import android.app.Activity;
 5 import android.app.Fragment;
 6 import android.os.Bundle;
 7 import android.view.LayoutInflater;
 8 import android.view.View;
 9 import android.view.View.OnClickListener;
10 import android.view.ViewGroup;
11 
12 public class Cehua_Fragment extends Fragment {
13     // 設置回調機制
14     private SetonCehuaFragmentClickListener mSetonCehuaFragmentClickListener;
15 
16     public interface SetonCehuaFragmentClickListener {
17         void loadxinwen();
18 
19         void loadyulexinwen();
20 
21         void loadtiyuxinwen();
22     }
23 
24     @Override
25     public void onAttach(Activity activity) {
26         super.onAttach(activity);
27         if (activity instanceof SetonCehuaFragmentClickListener) {
28             mSetonCehuaFragmentClickListener = (SetonCehuaFragmentClickListener) activity;
29         } else {
30             throw new RuntimeException(activity.toString() + " must implement 介面");
31         }
32     }
33 
34     @Override
35     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
36         View view = inflater.inflate(R.layout.cehua_menu, null);
37         return view;
38     }
39 
40     @Override
41     public void onActivityCreated(Bundle savedInstanceState) {
42         getView().findViewById(R.id.monixinweijiem).setOnClickListener(new OnClickListener() {
43 
44             @Override
45             public void onClick(View v) {
46                 mSetonCehuaFragmentClickListener.loadxinwen();
47             }
48         });
49         getView().findViewById(R.id.yulexinwen).setOnClickListener(new OnClickListener() {
50 
51             @Override
52             public void onClick(View v) {
53                 mSetonCehuaFragmentClickListener.loadyulexinwen();
54             }
55         });
56         getView().findViewById(R.id.tiyuxinwen).setOnClickListener(new OnClickListener() {
57 
58             @Override
59             public void onClick(View v) {
60                 mSetonCehuaFragmentClickListener.loadtiyuxinwen();
61             }
62         });
63 
64         super.onActivityCreated(savedInstanceState);
65     }
66 
67     public static Cehua_Fragment newFragment() {
68         Cehua_Fragment f = new Cehua_Fragment();
69         return f;
70     }
71 }
  1 package com.lixu.testjsonall.fragments;
  2 
  3 import java.util.ArrayList;
  4 import java.util.HashMap;
  5 import java.util.List;
  6 import com.google.gson.Gson;
  7 import com.lixu.testjsonall.R;
  8 import com.lixu.testjsonall.json_info.Info;
  9 import com.lixu.testjsonall.json_info.Infoall;
 10 import com.lixu.testjsonall.json_info.MerchantKey;
 11 import com.lixu.testjsonall.untils.Untils;
 12 import com.loopj.android.http.AsyncHttpClient;
 13 import com.loopj.android.http.TextHttpResponseHandler;
 14 import com.scxh.slider.library.SliderLayout;
 15 import com.scxh.slider.library.SliderTypes.BaseSliderView;
 16 import com.scxh.slider.library.SliderTypes.TextSliderView;
 17 import com.squareup.picasso.Picasso;
 18 import android.app.Activity;
 19 import android.app.Fragment;
 20 import android.content.Context;
 21 import android.os.Bundle;
 22 import android.view.LayoutInflater;
 23 import android.view.View;
 24 import android.view.View.OnClickListener;
 25 import android.view.ViewGroup;
 26 import android.widget.ArrayAdapter;
 27 import android.widget.ImageView;
 28 import android.widget.ProgressBar;
 29 import android.widget.TextView;
 30 import android.widget.Toast;
 31 import cz.msebera.android.httpclient.Header;
 32 import me.maxwin.view.XListView;
 33 import me.maxwin.view.XListView.IXListViewListener;
 34 
 35 public class Fragment_one extends Fragment {
 36     private String net_url = "http://192.168.1.124:8080/json/around";
 37     private MyAdapter mMyAdapter;
 38     private ProgressBar mProgressBar;
 39     private SliderLayout mSliderLayout;
 40     private XListView lv;
 41     // 兩種佈局指針
 42     private static final int TYPE_ONE = 0;
 43     private static final int TYPE_TWO = 1;
 44 
 45     // 設置回調機制
 46     private SetonFragmentOneClickListener mSetonFragmentOneClickListener;
 47 
 48     public interface SetonFragmentOneClickListener {
 49         void back();
 50 
 51     }
 52 
 53     @Override
 54     public void onAttach(Activity activity) {
 55         super.onAttach(activity);
 56         if (activity instanceof SetonFragmentOneClickListener) {
 57             mSetonFragmentOneClickListener = (SetonFragmentOneClickListener) activity;
 58         } else {
 59             throw new RuntimeException(activity.toString() + " must implement 介面");
 60         }
 61     }
 62 
 63     public static Fragment newFragment() {
 64         Fragment_one f = new Fragment_one();
 65         return f;
 66     }
 67 
 68     @Override
 69     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
 70         View view = inflater.inflate(R.layout.fragment_one, null);
 71         return view;
 72     }
 73 
 74     @Override
 75     public void onActivityCreated(Bundle savedInstanceState) {
 76         lv = (XListView) getView().findViewById(R.id.xlv);
 77         mProgressBar = (ProgressBar) getView().findViewById(R.id.progressbar);
 78         // 找到返回圖片按鈕 通過回調機制點擊設置返回
 79         getView().findViewById(R.id.fanhui).setOnClickListener(new OnClickListener() {
 80 
 81             @Override
 82             public void onClick(View v) {
 83                 mSetonFragmentOneClickListener.back();
 84 
 85             }
 86         });
 87 
 88         mMyAdapter = new MyAdapter(getActivity(), -1);
 89 
 90         View view = LayoutInflater.from(getActivity()).inflate(R.layout.listhead, null);
 91         mSliderLayout = (SliderLayout) view.findViewById(R.id.sliderlayout);
 92         // 將圖片坐標點移動到佈局右下角
 93         mSliderLayout.setPresetIndicator(SliderLayout.PresetIndicators.Right_Bottom);
 94         // 添加到listview頭部
 95         lv.addHeaderView(view);
 96 
 97         // 遍歷hashmap的方法
 98         HashMap<String, String> map = Untils.getData();
 99         for (String n : map.keySet()) {
100             String key = n;
101             String txt = map.get(key);
102             TextSliderView tsv = new TextSliderView(getActivity());
103             tsv.description(key);
104             tsv.image(txt);
105 
106             // 將滾動圖片根據邊框大小居中按正常圖片剪切顯示
107             tsv.setScaleType(BaseSliderView.ScaleType.CenterCrop);
108             mSliderLayout.addSlider(tsv);
109         }
110 
111         // 數據載入前顯示進度轉動條
112         lv.setEmptyView(mProgressBar);
113         lv.setAdapter(mMyAdapter);
114         // 初始獲取數據
115         GetAsynchttpdata();
116         // 設置上拉刷新
117         lv.setPullLoadEnable(true);
118         lv.setXListViewListener(new IXListViewListener() {
119 
120             @Override
121             public void onRefresh() {
122                 // 上拉獲取數據
123                 GetAsynchttpdata();
124                 // 設置刷新時間
125                 lv.setRefreshTime(Untils.formatTimeInMillis(System.currentTimeMillis()));
126             }
127 
128             @Override
129             public void onLoadMore() {
130                 // 下拉獲取數據
131                 GetAsynchttpdata();
132             }
133         });
134         super.onActivityCreated(savedInstanceState);
135     }
136 
137     // 第三方獲取網路數據類
138     private void GetAsynchttpdata() {
139         AsyncHttpClient ahc = new AsyncHttpClient();
140         ahc.get(net_url, new TextHttpResponseHandler() {
141             // 通過網路地址解析Json數據成String類型
142             @Override
143             public void onFailure(int arg0, Header[] arg1, String arg2, Throwable arg3) {
144                 Toast.makeText(getActivity(), "錯誤!", 0).show();
145 
146             }
147 
148             @Override
149             public void onSuccess(int arg0, Header[] arg1, String arg2) {
150                 // 從字元串中解析json文件
151                 Gson gson = new Gson();
152                 Infoall infoall = gson.fromJson(arg2, Infoall.class);
153                 Info info = infoall.getInfo();
154                 List<MerchantKey> mMerchantKey = info.getMerchantKey();
155                 mMyAdapter.setList(mMerchantKey);
156                 // 刷新完畢後停止上拉和下拉刷新圖標顯示
157                 lv.stopRefresh();
158                 lv.stopLoadMore();
159 
160             }
161         });
162 
163     }
164 
165     private class MyAdapter extends ArrayAdapter {
166 
167         private LayoutInflater flater;
168         private List<MerchantKey> data = new ArrayList<MerchantKey>();
169         private Context context;
170 
171         public MyAdapter(Context context, int resource) {
172             super(context, resource);
173             this.context = context;
174             flater = LayoutInflater.from(context);
175         }
176 
177         public void setList(List<MerchantKey> data) {
178             this.data = data;
179             mMyAdapter.notifyDataSetChanged();
180         }
181 
182         // 第一種佈局
183         public View getViewOne(int position, View convertView, ViewGroup parent) {
184 
185             Viewdata mviewdata = null;
186             if (convertView == null) {
187                 // 一級優化,view可以復用緩存
188                 mviewdata = new Viewdata();
189                 convertView = flater.inflate(R.layout.list, null);
190                 mviewdata.biaoti = (TextView) convertView.findViewById(R.id.list_name_txt);
191                 mviewdata.biaoti2 = (TextView) convertView.findViewById(R.id.list_coupe_txt);
192                 mviewdata.dizhi = (TextView) convertView.findViewById(R.id.list_location_txt);
193                 mviewdata.juli = (TextView) convertView.findViewById(R.id.list_distance_txt);
194                 mviewdata.jpg = (ImageView) convertView.findViewById(R.id.list_icon_img);
195                 mviewdata.tuan = (ImageView) convertView.findViewById(R.id.list_group_img);
196                 mviewdata.quan = (ImageView) convertView.findViewById(R.id.list_ticket_img);
197                 mviewdata.ka = (ImageView) convertView.findViewById(R.id.list_card_img);
198                 convertView.setTag(mviewdata);
199             }
200             // 二級優化 ,只找到一次控制項,不會每次都通過R文件找到控制項
201             mviewdata = (Viewdata) convertView.getTag();
202             mviewdata.biaoti.setText(data.get(position).getName());
203             mviewdata.biaoti2.setText(data.get(position).getCoupon());
204             mviewdata.dizhi.setText(data.get(position).getLocation());
205             mviewdata.juli.setText(data.get(position).getDistance());
206             Picasso.with(context).load(data.get(position).getPicUrl()).into(mviewdata.jpg);
207 
208             if (data.get(position).getGroupType().equals("YES")) {
209                 mviewdata.tuan.setVisibility(View.VISIBLE);
210             } else {
211                 mviewdata.tuan.setVisibility(View.GONE);
212             }
213             if (data.get(position).getCardType().equals("YES")) {
214                 mviewdata.ka.setVisibility(View.VISIBLE);
215             } else {
216                 mviewdata.ka.setVisibility(View.GONE);
217             }
218             if (data.get(position).getCouponType().equals("YES")) {
219                 mviewdata.quan.setVisibility(View.VISIBLE);
220             } else {
221                 mviewdata.quan.setVisibility(View.GONE);
222             }
223 
224             return convertView;
225 
226         }
227 
228         // 第二種佈局
229         public View getViewTwo(int position, View convertView, ViewGroup parent) {
230 
231             Viewdata2 mviewdata2 = null;
232             if (convertView == null) {
233                 // 一級優化,view可以復用緩存
234                 mviewdata2 = new Viewdata2();
235                 convertView = flater.inflate(R.layout.list2, null);
236                 mviewdata2.biaoti2 = (TextView) convertView.findViewById(R.id.list_name_txt2);
237                 mviewdata2.biaoti22 = (TextView) convertView.findViewById(R.id.list_coupe_txt2);
238                 mviewdata2.juli2 = (TextView) convertView.findViewById(R.id.list_distance2_txt);
239                 mviewdata2.jpg2 = (ImageView) convertView.findViewById(R.id.list_icon_img2);
240                 convertView.setTag(mviewdata2);
241             }
242             // 二級優化 ,只找到一次控制項,不會每次都通過R文件找到控制項
243             mviewdata2 = (Viewdata2) convertView.getTag();
244             mviewdata2.biaoti2.setText(data.get(position).getName());
245             mviewdata2.biaoti22.setText(data.get(position).getCoupon());
246             mviewdata2.juli2.setText(data.get(position).getDistance());
247             Picasso.with(context).load(data.get(position).getPicUrl()).into(mviewdata2.jpg2);
248 
249             return convertView;
250 
251         }
252 
253         // 控制項類
254         private class Viewdata {
255             TextView biaoti;
256             TextView biaoti2;
257             TextView dizhi;
258             TextView juli;
259             ImageView jpg;
260             ImageView tuan;
261             ImageView quan;
262             ImageView ka;
263 
264         }
265 
266         // 第二個佈局的控制項類
267         private class Viewdata2 {
268             TextView biaoti2;
269             TextView biaoti22;
270             TextView juli2;
271             ImageView jpg2;
272 
273         }
274 
275         @Override
276         public View getView(int position, View convertView, ViewGroup parent) {
277             if (getItemViewType(position) == TYPE_ONE) {
278                 return getViewOne(position, convertView, parent);
279             } else {
280                 return getViewTwo(position, convertView, parent);
281             }
282         }
283 
284         @Override
285         public int getItemViewType(int position) {
286             // 設置對大小寫不敏感 --equalsIgnoreCase
287             if (data.get(position).getCouponType().equalsIgnoreCase("YES")) {
288                 return TYPE_ONE;
289 
290             } else {
291                 return TYPE_TWO;
292             }
293 
294         }
295 
296         // 獲取返回view的兩種類型 不寫這個方法容易報錯誤。。
297         @Override
298         public int getViewTypeCount() {
299             return 2;
300         }
301 
302         @Override
303         public int getCount() {
304 
305             return data.size();
306         }
307 
308     }
309 
310     // 程式退出時銷毀
311     @Override
312     public void onDestroy() {
313         super.onDestroy();
314         if (mSliderLayout != null) {
315             mSliderLayout.stopAutoCycle();
316             mSliderLayout = null;
317         }
318     }
319 
320 }
 1 package com.lixu.testjsonall.fragments;
 2 
 3 import com.lixu.testjsonall.R;
 4 import android.app.Activity;
 5 import android.app.Fragment;
 6 import android.os.Bundle;
 7 import android.view.LayoutInflater;
 8 import android.view.View;
 9 import android.view.View.OnClickListener;
10 import android.view.ViewGroup;
11 
12 public class Fragment_tiyuxinwen extends Fragment {
13     // 設置回調機制
14     private SetonFragmentTiyuxinwenClickListener mSetonFragmentTiyuxinwenClickListener;
15 
16     public interface SetonFragmentTiyuxinwenClickListener {
17         void back();
18 
19     }
20 
21     @Override
22     public void onAttach(Activity activity) {
23         super.onAttach(activity);
24         if (activity instanceof SetonFragmentTiyuxinwenClickListener) {
25             mSetonFragmentTiyuxinwenClickListener = (SetonFragmentTiyuxinwenClickListener) activity;
26         } else {
27             throw new RuntimeException(activity.toString() + " must implement 介面");
28         }
29     }
30 
31     public static Fragment newFragment() {
32         Fragment_tiyuxinwen f = new Fragment_tiyuxinwen();
33         return f;
34     }
35 
36     @Override
37     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
38         return inflater.inflate(R.layout.yulexinwen, null);
39     }
40 
41     @Override
42     public void onActivityCreated(Bundle savedInstanceState) {
43         super.onActivityCreated(savedInstanceState);
44         getView().findViewById(R.id.fanhui).setOnClickListener(new OnClickLis

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 本文目錄列表:1、從MySQL提供的TO_DAYS和FROM_DAYS這對函數說起2、SQL Server日期時間粒度3、SQL Server周有關時間粒度4、總結語5、參考清單列表從MySQL提供的TO_DAYS和FROM_DAYS針對函數說起 學習和使用過MySQL的博友,大都知道MySQL提供...
  • 原文地址:http://blog.itpub.net/7478833/viewspace-441043/感謝作者in 和 exists區別in 是把外表和內表作hash join,而exists是對外表作loop,每次loop再對內表進行查詢。一直以來認為exists比in效率高的說法是不准確的。如...
  • 一個防止誤刪MSSQL資料庫的方法環境:Windows2008 R2 、SQL 2012今天發現一個有趣的現象,之前資料庫伺服器的其中幾個資料庫做過鏡像,不過現在已經刪除了,今天又要在那台伺服器上為一個庫搭建鏡像搭建鏡像的過程中,把鏡像機器的ip寫成了自己的ip,結果發現命令成功執行--備機上執行U...
  • 1 select * from sysobjects where xtype='PK'此條語句使用的場景: 當我們使用sql語句創建表的時候,可以給表中的id列添加check約束和標識列約束,主鍵約束... 當我們添加表成功後,進資料庫中區查看check約束的時候,是不會有check約束的名字的.....
  • 普通GUID 會發生很大的頁分裂情況,這在一個表反覆修改的情況下,可能會明顯影響查詢速度。
  • 步驟:1,選擇要插入的資料庫--右鍵--任務--導入數據2,點擊下一步,選擇數據源,excel文件路徑,和版本信息(註:使用2010及以上版本的office,請先將格式轉換為03 或07格式的以便識別)3,選擇目標資料庫4,執行成功5,查看導入數據,可以重命名以上就是資料庫導入excel文件的步驟,...
  • ImageView的講解一、src和background的區別background我們通常理解是背景,而src是內容,當使用src填入圖片的時候是以圖片的大小直接填充,並不會進行拉伸,而background填入圖片會根據指定的大小對圖片進行縮放拉伸。 當我們設置寬和高都...
  • 原網址 : http://www.cnblogs.com/zdz8207/archive/2012/11/30/eclipse android adt update.html網上解決方法主要有這幾種 :1.有時候eclipse不自動編譯,把project clean一下,讓R.java重新生成 2....
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...