生活随笔
收集整理的這篇文章主要介紹了
不写代码也能实现android应用
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
如何實不寫代碼實現android應用
是一套基于一整套開發框架實現的基于databinding實現不需要寫java代碼來實現簡單的應用。
可以實現大部分頁面功能,歷時兩周實現此功能。等待在項目只實踐,如有補充歡迎提出。轉載請標明出處。
測試apk其中 ”自動frame測試“ 按鈕點擊后的所有內容即為本文中的代碼實現
點擊下載 https://pan.baidu.com/s/1nvonPrz
- 實現登陸頁面,實現登陸并進入下一個頁面。登陸需要輸入3個參數 門店名稱,賬號,密碼,其中賬號必須是數字,密碼需要轉換為md5。
<?xml version="1.0" encoding="UTF-8"?><layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"><data><variable
name="F"type="com.mdx.framework.autofit.AutoFit" /><variable
name="P"type="java.util.HashMap" /><import type="com.udows.canyin.proto.ApisFactory"></import><import type="com.mdx.framework.commons.verify.Md5"></import></data><com.mdx.framework.autofit.layout.FitLinearLayout
android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><EditText
android:id="@+id/store"android:layout_width="match_parent"android:layout_height="48dip"android:background="@color/colorPrimary"android:gravity="center"android:text="002@458996"android:textSize="20sp" /><EditText
android:id="@+id/name"android:layout_width="match_parent"android:layout_height="48dip"android:background="@color/colorPrimary"android:gravity="center"android:text="001"android:textSize="20sp" /><EditText
android:id="@+id/psw"android:layout_width="match_parent"android:layout_height="48dip"android:background="@color/colorPrimary"android:gravity="center"android:text="123456"android:textSize="20sp" /><Button
android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="登陸"android:onClick='@{(v)->F.save(ApisFactory.getApiEmpLogin().set((String)F.V(@id/store),(String)F.V(@id/name,F.NUM,"門店"),Md5.mD5((String)F.V(@id/psw)),"android","111111111"),"@user").CKERR().close().startActivity(@layout/frg_autofittest,F.CV("state","1"))}'/></com.mdx.framework.autofit.layout.FitLinearLayout>
</layout>
-** 布局中主要綁定登陸按鈕的事件解釋如下。
(String)F.V(@id/name,F.NUM,"門店") //獲取name的值,驗證器使用NUM即數字驗證器,提示字段為門店F.save(...,"@user") //獲取接口數據并保存,第一個參數為接口類,@user為保存數據名@是全局保存,全局保存后可以在任意位置獲取此參數。CKERR() //驗證接口錯誤,如果有錯誤則中斷執行,否則向下執行close() //關閉當前頁面.startActivity() //打開新的頁面,新的頁面加載@layout/frg_autofittest這個布局,并且傳遞F.CV("state","1") state 和1 的參數
-** 顯示效果如下
-** 點擊后進入列表頁。頁面是一個列表頁是顯示一個根據服務器數據顯示的一個列表。有篩選功能。
<?xml version="1.0" encoding="UTF-8"?><layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"><data><variable
name="item"type="com.mdx.framework.server.api.base.Msg_Update" /><variable
name="F"type="com.mdx.framework.autofit.AutoFit" /><variable
name="P"type="java.util.HashMap" /><import type="com.udows.canyin.proto.ApisFactory"></import><import type="com.mdx.framework.commons.verify.Md5"></import></data><com.mdx.framework.autofit.layout.FitLinearLayout
android:layout_width="match_parent"android:layout_height="match_parent"android:background="#fff"android:orientation="vertical"app:saveApi='@{F.listSet(ApisFactory.getApiEmpKcOrders().set((String)P["state"]),@layout/item_kc)}'><TextView
android:id="@+id/title"android:layout_width="match_parent"android:layout_height="48dip"android:background="@color/colorPrimary"android:gravity="center"android:text="@{item.url}"android:textSize="20sp" /><LinearLayout
android:layout_width="match_parent"android:layout_height="wrap_content"><TextView
android:layout_width="match_parent"android:layout_weight="1"android:layout_height="40dip"android:gravity="center"android:onClick="@{(v)->F.dialog(@layout/pop_select)}"android:text='@{P["flname"]??"all"}'/><TextView
android:layout_width="match_parent"android:layout_weight="1"android:layout_height="40dip"android:gravity="center"android:onClick="@{(v)->F.pop(v,@layout/frg_autofittest)}"android:text='@{P["flname"]??"all"}'/></LinearLayout><com.mdx.framework.widget.pagerecycleview.MFRecyclerView
android:id="@+id/mrecycleview"android:layout_width="match_parent"android:layout_height="300dip"android:minHeight="200dip"android:layout_weight="1"app:column="1" /><LinearLayout
android:layout_width="match_parent"android:layout_height="50dip"><LinearLayout
android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:orientation="vertical"><com.mdx.framework.widget.MImageView
android:id="@+id/icon1"android:layout_width="25dip"android:layout_height="22dip"android:src="@mipmap/tylt_bt_shouye_n" /><TextView
android:id="@+id/txt"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="3dip"android:text="首頁"android:textSize="12sp" /></LinearLayout><LinearLayout
android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:orientation="vertical"><com.mdx.framework.widget.MImageView
android:id="@+id/icon2"android:layout_width="25dip"android:layout_height="22dip"android:src="@mipmap/tylt_bt_feilei_n" /><TextView
android:id="@+id/txt2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="5dip"android:text="分類"android:textSize="12sp" /></LinearLayout><LinearLayout
android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:orientation="vertical"><com.mdx.framework.widget.MImageView
android:id="@+id/icon4"android:layout_width="25dip"android:layout_height="22dip"android:src="@mipmap/tylt_bt_luntan_n" /><TextView
android:id="@+id/txt3"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="3dip"android:text="論壇"android:textSize="12sp" /></LinearLayout><LinearLayout
android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:gravity="center"android:orientation="vertical"><com.mdx.framework.widget.MImageView
android:id="@+id/icon3"android:layout_width="25dip"android:layout_height="22dip"android:src="@mipmap/tylt_bt_wo_n" /><TextView
android:id="@+id/txt4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="3dip"android:text="我的"android:textSize="12sp" /></LinearLayout></LinearLayout></com.mdx.framework.autofit.layout.FitLinearLayout>
</layout>
'@{F.listSet(ApisFactory.getApiEmpKcOrders().set((String)P["state"]),@layout/item_kc)}F.listSet(ApiUpdate,res) //為頁面中的list設置接口類,和顯示的cell的形式
P["state"] //取頁面傳遞以及接口設置的參數,如需要區全局的可以使用@前綴@{(v)->F.dialog(@layout/pop_select) //彈出 @layout/pop_select 布局的dialog
@{(v)->F.pop(v,@layout/pop_select) //彈出 @layout/pop_select 布局的popwindow
- **篩選布局窗口 主要功能彈出多種狀態,點擊后關閉彈出框并且傳遞參數給列表并刷新。
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"><data><variable
name="F"type="com.mdx.framework.autofit.AutoFit" /><variable
name="P"type="java.util.HashMap" /></data><LinearLayout
android:layout_width="match_parent"android:layout_height="wrap_content"android:background="#fff"android:orientation="vertical"><TextView
android:id="@+id/state_all"android:layout_width="match_parent"android:layout_height="40dip"style="@style/kcxdselectpop"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","0","flname","all").close()}'android:text="全部" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><TextView
android:id="@+id/state_dfk"android:layout_width="match_parent"android:layout_height="40dip"style="@style/kcxdselectpop"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","1","flname","dfk").close()}'android:text="待付款" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><TextView
android:id="@+id/state_djd"android:layout_width="match_parent"android:layout_height="40dip"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","2","flname","djd").close()}'style="@style/kcxdselectpop"android:text="待接單" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><TextView
android:id="@+id/state_yjd"android:layout_width="match_parent"android:layout_height="40dip"style="@style/kcxdselectpop"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","3","flname","yjd").close()}'android:text="已接單" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><TextView
android:id="@+id/state_yjud"android:layout_width="match_parent"android:layout_height="40dip"style="@style/kcxdselectpop"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","4","flname","ysd").close()}'android:text="已拒單" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><TextView
android:id="@+id/state_yqx"android:layout_width="match_parent"android:layout_height="40dip"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","5","flname","yqx").close()}'style="@style/kcxdselectpop"android:text="已取消" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><TextView
android:id="@+id/state_ywc"android:layout_width="match_parent"android:layout_height="40dip"android:onClick='@{()->F.setParams(@layout/frg_autofittest,"state","0","flname","ywc").close()}'style="@style/kcxdselectpop"android:text="已完成" /><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View></LinearLayout>
</layout>
'@{()->F.setParams(@layout/frg_autofittest,"state","0","flname","ywc").close()}'
F.setParams(resid,...) //給一個布局傳遞參數 resid,參數以鍵值對方式傳遞。傳遞后會根據設置刷新頁面。
.close() //關閉窗口
- *Cell數據顯示如下,顯示服務器的數據,并且實現一個點擊功能,點擊后顯示一個loading按鈕并且數據加載完成后關閉
<?xml version="1.0" encoding="UTF-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"><data><import type="android.view.View" /><import type="android.text.TextUtils" /><variable
name="F"type="com.mdx.framework.autofit.AutoFit" /><variable
name="P"type="java.util.HashMap" /><variable
name="item"type="com.udows.canyin.proto.MOrderInfo" /><variable
name="clickListener"type="android.view.View.OnClickListener" /><import type="com.udows.canyin.proto.ApisFactory"></import></data><LinearLayout
android:layout_width="match_parent"android:layout_height="wrap_content"><LinearLayout
android:layout_width="match_parent"android:layout_height="120dip"android:layout_marginTop="10dip"android:layout_marginLeft="5dip"android:onClick='@{(v)->F.visable(@id/process_jd,View.VISIBLE).save(ApisFactory.getApiEmpLogin().set("111","111","111","android","111111111"),"@user").visable(@id/process_jd,View.GONE).toast("wancheng")}'android:layout_marginRight="5dip"android:orientation="vertical"><RelativeLayout
android:layout_width="match_parent"android:layout_height="55dip"android:layout_marginLeft="10dip"android:layout_marginRight="10dip"android:gravity="top"android:orientation="vertical"><TextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="10dip"android:text="@{item.code}"android:textColor="#262626"android:textSize="13dip" /><TextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="30dip"android:text="@{item.time}"android:textColor="#262626"android:textSize="13dip" /><TextView
android:id="@+id/state"style="@style/text_style_11_white"android:layout_width="52dip"android:layout_height="25dip"android:layout_alignParentRight="true"android:layout_marginRight="5dip"android:gravity="center_horizontal"android:paddingTop="3dip"android:textSize="12dip" /></RelativeLayout><View
android:layout_width="match_parent"android:layout_height="1px"android:layout_marginLeft="10dip"android:layout_marginRight="10dip"android:background="#eee"></View><View
android:layout_width="match_parent"android:layout_height="1px"android:background="#eee"></View><RelativeLayout
android:layout_width="match_parent"android:layout_height="0dp"android:layout_marginLeft="10dip"android:layout_marginRight="10dip"android:layout_weight="1"><TextView
android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="10dip"android:text='@{item.desk}'android:layout_marginRight="100dip"android:textColor="#262626"android:textSize="13dip" /><TextView
android:id="@+id/paystate"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginRight="5dp"android:layout_marginTop="34dp"android:gravity="center"android:paddingBottom="2dip"android:paddingLeft="8dip"android:paddingRight="8dip"android:paddingTop="2dip"android:textSize="10dip" /><LinearLayout
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:gravity="bottom"android:paddingTop="10dip"><TextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:gravity="center_horizontal"android:text="¥"android:textColor="#e73b3b"android:textSize="12dip" /><TextView
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentRight="true"android:gravity="center_horizontal"android:text="@{item.amount}"android:textColor="#e73b3b"android:textSize="17dip" /></LinearLayout><LinearLayout
android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_alignParentBottom="true"android:layout_alignParentRight="true"android:layout_marginBottom="3dip"android:gravity="bottom"android:paddingTop="10dip"><RelativeLayout
android:id="@+id/btn_td"android:layout_width="50dip"android:layout_height="25dip"android:gravity="center_horizontal|bottom"android:orientation="vertical"android:visibility="@{(item.state==2)?View.VISIBLE:View.GONE}"><TextView
android:layout_width="match_parent"android:layout_height="match_parent"android:gravity="center"android:singleLine="true"android:text="拒單"android:textSize="14dip" /><ImageView
android:layout_width="50dip"android:layout_height="2dip"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:layout_marginTop="3dip" /><ProgressBar
android:id="@+id/process_td"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#ffffff"android:visibility="gone" /></RelativeLayout><RelativeLayout
android:id="@+id/btn_jd"android:layout_width="50dip"android:layout_height="25dip"android:layout_marginLeft="15dip"android:gravity="center_horizontal|bottom"android:orientation="vertical"><TextView
android:layout_width="match_parent"android:layout_height="match_parent"android:layout_alignParentTop="true"android:gravity="center"android:singleLine="true"android:text="接單"android:textSize="14dip" /><ImageView
android:layout_width="50dip"android:layout_height="2dip"android:layout_alignParentBottom="true"android:layout_centerHorizontal="true"android:layout_marginTop="3dip" /><ProgressBar
android:id="@+id/process_jd"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#ffffff"android:visibility="gone"/></RelativeLayout></LinearLayout></RelativeLayout></LinearLayout></LinearLayout>
</layout>
-* 其中apiuodate是封裝好的接口調用類
-** MFRecyclerView是封裝好的recyclerview實現頁面的布局顯示。 github上可以看到源碼。https://github.com/ryanliu19843/pagerecycleview
-** MImageview是封裝的imageview 實現圖片變色動畫顯示等。
github上可以看到源碼。https://github.com/ryanliu19843/XImageView
測試apk如下其中
”自動frame測試“ 按鈕點擊后的所有內容即為本文中的代碼實現
https://pan.baidu.com/s/1nvonPrz
總結
以上是生活随笔為你收集整理的不写代码也能实现android应用的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。