请选择 进入手机版 | 继续访问电脑版

登录  | 立即注册

游客您好!登录后享受更多精彩

查看: 1323|回复: 0

[lua教程] 【lua教程】舔狗日记

[复制链接]

444

主题

509

帖子

2051

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2051

荣誉管理论坛元老

发表于 2021-7-1 08:38:58 来自手机 | 显示全部楼层 |阅读模式 来自:
  1. require "import"9 @0 b' d5 W* {: ~* [
  2. import "android.app.*"
    4 \6 }6 h$ O) [  R6 O
  3. import "android.os.*"
    . Q6 w+ i2 O' v) c- U6 w, A
  4. import "android.widget.*"
    6 M* N4 t$ l6 D3 @& v7 J8 m
  5. import "android.view.*"' U7 r: E  V- [2 X  |
  6. layout={  \- u' P8 Q3 B% ]
  7.   LinearLayout;/ z: A5 ]( X4 U: t- O8 J& A5 K" O
  8.   orientation="vertical";
    ! T1 d6 \3 w0 Y/ M
  9.   layout_height="fill";$ {3 ?, g4 U, j0 ?
  10.   layout_width="fill";
    5 N( ?3 U7 G4 Y1 V( \# K
  11.   {1 E& W  w6 D7 \6 L" H2 P0 I. s: X
  12.     LinearLayout;
    $ r- M5 x1 V, f. ^- k
  13.     orientation="vertical";
    $ d& J2 o: H, D" v
  14.     layout_width="match_parent";7 M$ x( m  f0 d/ l
  15.     backgroundColor="0xFFF2F2F2";" w& x! e, D* c/ w/ K; g+ [0 L+ s
  16.     layout_weight="3";
    : o& X$ F) q6 d7 y7 b  O0 J
  17.     layout_height="match_parent";
    ! C4 B3 e" V% g6 E% E! T
  18.     {+ g. q  U% g; ]& @
  19.       CardView;
    + a: f* W1 P+ c9 |% z
  20.       layout_gravity="center";
    7 Z0 E2 @3 E+ ]4 A4 o
  21.       layout_margin="30dp";" D1 D8 _( x+ G
  22.       CardElevation="1";
    4 @$ u6 N) ]8 c5 c
  23.       backgroundColor="0xFFFFFFFF";& E# x! E9 d0 G; F& S
  24.       radius="15dp";
    0 z& j" m7 H( z& H" t
  25.       layout_width="match_parent";
    ! N1 l9 u# v& U% I1 s
  26.       layout_height="wrap_content";
    , j4 w2 K% U7 f3 {4 p& Q- d
  27.       {8 U( V$ w6 L4 H7 j; {( q5 [
  28.         LinearLayout;
    0 f; k; j! E$ `1 `' l% ]; |% n
  29.         orientation="vertical";4 s+ ?# `3 e+ o# T) @! o
  30.         layout_height="match_parent";
    + c% O. t) v, j3 I( G
  31.         layout_width="match_parent";2 _7 M5 x% a* M
  32.      % [$ I4 Z7 q7 x- {/ B1 y' u
  33.         {' }. l8 x. J- i
  34.           TextView;
    # o  y& ]; B& n' U6 [( ]
  35.           id="舔狗日记";
    + C; K( ?( q; ?. D8 o) v3 S
  36.           layout_marginBottom="15dp";+ C& G7 o! a- p) f* @
  37.           gravity="center|top";
    " _1 @' u* E3 Q+ u/ _
  38.           textColor="0xB2000000";' p- O" k: S- s& `' V
  39.           textSize="16sp";
    0 ]4 J; D. o+ z( ^
  40.           layout_marginRight="20dp";- a% }! E6 e/ l+ u" v/ W
  41.           layout_weight="1";
    # O# Y- C6 Y  @2 H" x; n2 X; k9 {
  42.           layout_width="match_parent";
    6 @0 X4 L# V8 H, W" F
  43.           paddingTop="20dp";: M# t; U. z) u% E9 U, s
  44.           text="舔狗日记";
    # k+ y) R: E( Y) k, l
  45.           layout_marginLeft="20dp";# n$ i) y/ F9 K# k. _
  46.           layout_height="match_parent";
    ! ~% c6 \% {% n$ u
  47.         };3 K1 o5 u; M3 e4 ~( U
  48.       };
    3 d% ^) |( @% x2 t4 }
  49.     };+ S9 j) F0 z5 u5 r  y
  50.     {
    5 c7 |& R$ f! {  S* p
  51.       LinearLayout;# y8 `$ h7 g$ j1 c. _5 o$ k5 s' Z
  52.       layout_height="match_parent";+ Z( B. ?* B: c% T
  53.       gravity="center|top";
    ; e0 Q8 c- g- ?9 `
  54.       layout_width="match_parent";3 }4 U1 J% K1 n  R4 i8 h1 q
  55.       {# {/ R$ V0 v; ^" \8 W
  56.         Button;- D: L0 O" F9 f* S- v( G+ i
  57.         id="刷新";
    & S, F+ Z& F0 D
  58.         text="刷新";/ \. a7 E4 Y6 Y" F1 }8 F
  59.         layout_width="100dp";% y' K& [( d( I' i9 O4 R
  60.         layout_marginLeft="16dp";6 F2 ~  T# [0 n9 S9 ^& z9 v$ O0 ?
  61.         textColor="0xFFFFFFFF";* N: f$ t1 b4 \& z5 v
  62.       };. k8 n( B& ~! Y7 a5 R0 s$ A
  63.       {
    1 U0 k  J2 i6 `3 K" B/ |# }
  64.         Button;
    0 A% p+ U4 R5 j- w; D7 B; M3 q. d
  65.         layout_marginRight="8dp";: q$ d" m2 k9 L% |
  66.         id="复制";5 M- a. q$ n. [. @
  67.         layout_width="100dp";5 t' f1 P0 h% g8 q- T; Q
  68.         text="复制";6 s# J; R& s, i; b( P& T. d) x
  69.         layout_marginLeft="8dp";9 Y4 v/ y% S" x0 q$ x( b% {1 {
  70.         textColor="0xFFFFFFFF";5 e0 p% e2 I2 q( f
  71.       };4 p2 `" D9 H* L) }' M8 l( B$ W
  72.       {* u8 @4 J& M) F0 [8 H/ r
  73.         Button;. [4 w( W+ c6 I9 K$ `, O# V7 a
  74.         layout_marginRight="16dp";, w! i4 O; r, h; D  E) _/ T
  75.         id="转发";% a6 s/ |5 m& L1 B
  76.         layout_width="100dp";
    " x  ^7 Z& ]9 K# Y; q2 o6 v
  77.         text="转发";
      P8 c+ Y0 k, t7 f8 G; b
  78.         textColor="0xFFFFFFFF";
    7 l7 q  v1 d$ ~: ?2 t5 D
  79.       };
      @* H5 H& i* q) W3 F" I
  80.     };
    , U. j: G& ^, a+ g6 Z
  81.   };" M/ v4 _. T/ z% X; p1 p2 V: m
  82. };9 k3 j' ]  U7 Q+ E  V2 L* d
  83. 5 o6 V0 S9 Y' J" a  ^- }
  84. activity.setTheme(android.R.style.Theme_DeviceDefault_Light)--设置md主题
    2 }/ ^% v+ s7 ~$ y9 b+ ]
  85. + Z6 e. f' ?& u! b, y
  86. activity.setTitle("舔狗日记")
    9 z; t! G9 v7 @4 \
  87. activity.setContentView(loadlayout(layout))
    : y6 l( P% |. K; e
  88. activity.overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out)
    ) q& s0 w0 l: r4 S+ Z, C( w; V
  89. import "android.graphics.drawable.ColorDrawable"
    4 A* w9 \% R1 x$ c# t8 e' J+ h
  90. activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS).setStatusBarColor(0xFFF2F2F2);
    6 `8 V1 J% ~4 u  F
  91. activity.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);& Z9 C7 K/ q) C: ^
  92. activity.ActionBar.hide()
    / p3 @% L0 J" N, q5 I, I

  93. . E1 q) f( L$ l: G* _
  94. function 控件圆角(view,InsideColor,radiu)$ x3 Y7 x8 e3 ~5 ~& x5 r8 A# m
  95.   import "android.graphics.drawable.GradientDrawable"9 E9 y. ?$ M! \7 g2 z
  96.   drawable = GradientDrawable()) \7 Z7 x5 I" Y" x6 A
  97.   drawable.setShape(GradientDrawable.RECTANGLE)
    / G  U) P% h6 X* o$ A( [8 {
  98.   drawable.setColor(InsideColor)
    0 I7 H" b9 D3 Z; _/ X. ~
  99.   drawable.setCornerRadii({radiu,radiu,radiu,radiu,radiu,radiu,radiu,radiu});
    9 `' r+ s7 a0 Y
  100.   view.setBackgroundDrawable(drawable)
    3 \" F( a4 O" ~5 v. ~! A
  101. end
    ( ^% y4 x3 L$ B- @$ e( I/ p
  102. 7 K9 q, ]% P% K0 c, x0 W5 q" n) z& X* D
  103. function 复制内容到剪切板(内容)
    / T* \; J  K' c. n$ E; l' Z% K+ ^4 r
  104.   import "android.content.*"9 F! \9 Q8 K- ]' u2 R
  105.   activity.getSystemService(Context.CLIPBOARD_SERVICE).setText(内容)4 l: Y& {- s3 y% {7 a
  106. end
    3 `, ^9 m+ X$ W. i4 Z, B

  107. : k, ^# a& X( O
  108. function 分享内容(内容)8 e' @$ [, M2 N( m' t% k
  109.   import "android.content.*"8 k' g: U  O6 V! c, T
  110.   intent=Intent(Intent.ACTION_SEND);
    1 k  S4 @: w. S, n+ I0 ^5 h
  111.   intent.setType("text/plain");
    , v& i) r0 X5 |7 g6 T
  112.   intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
    ' `4 T" u9 P/ c& h$ `* R4 [
  113.   intent.putExtra(Intent.EXTRA_TEXT, 内容);9 m7 v1 u: a$ N9 V0 F6 i! b
  114.   intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    : G) P- k! O; J4 H2 \, b% a- Y+ S
  115.   activity.startActivity(Intent.createChooser(intent,"分享到:"));
    5 w/ w5 E/ V* J% Q( W
  116. end
    ! G* m. n( f9 _2 r
  117. 5 I# J7 i! L# d/ t5 M) e8 M/ f! }
  118. 控件圆角(刷新,0xAF000000,35)/ T. W+ _1 b# {2 ^" _
  119. 控件圆角(复制,0xAF000000,35)
    1 _+ d* Z9 B6 F! Z) w
  120. 控件圆角(转发,0xAF000000,35)
    , H. y- C6 B4 d6 ]& Z

  121. 0 S8 Y4 `4 x$ ?( `" ]. E9 b% J
  122. 刷新.onClick=function()4 @6 o/ F* Y8 `1 T
  123.   获取日记()$ J% Q: \5 I: k- N$ I
  124. end9 u$ p9 F' x, z# l; N* B# c. U
  125. 复制.onClick=function()
    2 `' g9 p$ [# j6 S' h5 A
  126.   复制内容到剪切板(舔狗日记.text)
    6 S( ?" _2 w$ E" ]+ \& m( I, `  e) B
  127.   print("已复制到剪切板")
    * h3 q2 J% N% @, u
  128. end
    & g+ ?) v4 s: W2 ^1 N
  129. 转发.onClick=function()
    7 ^* c+ o3 m6 w2 f' ~
  130.   分享内容(舔狗日记.text)
    7 h: A' a1 z2 a) w1 M/ {1 O
  131. end/ ~! j8 [9 m' n: M0 t
  132. cjson=import "cjson"3 \) W, O* c- O
  133. import "http"
    + I2 X7 z" Z( A$ Q  `1 g" U
  134. --api来源于网络
    0 O/ f. \- ]) j
  135. function 获取日记()5 ~8 m1 K5 Z: g
  136.   Http.get("https://cloud.qqshabi.cn/api/tiangou/api.php",nil,"utf-8",nil,function(a,b,c,d)' F; z3 N! |% N/ f4 u
  137.     if a==200
    - p# v9 N. T: ]; T8 I5 `4 ~
  138.       舔狗日记.setText(b). O! g9 w2 [. ^* P; o$ d+ S3 w
  139.     end- [  [, S1 H/ j2 ^. y0 x. F
  140.   end)& l( }0 U5 W- U' l' t6 g( |
  141. end
    : l+ [* g( Z% I8 U* `2 n: r
  142. 获取日记()
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|星空社区 |网站地图

GMT+8, 2024-3-28 22:15 , Processed in 0.048598 second(s), 23 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表