留言本代码

优秀源码 无标签
1 533
wz2021
wz2021 潜伏站长 2023-02-28 20:11:39
Lv:2级


require "import"

import "android.app.*"

import "android.os.*"

import "android.widget.*"

import "android.view.*"

--import "layout"

import "android.content.Context"

--activity.actionBar.hide()

activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

layout={

  LinearLayout;

  orientation="vertical";

  layout_width="match_parent";

  layout_height="match_parent";

  {

    LinearLayout;

    backgroundColor="0xFF009AFF";

    layout_height="80dp";

    layout_width="match_parent";

    {

      LinearLayout;

      layout_height="match_parent";

      gravity="center";

      layout_width="wrap_content";

      {

        TextView;

        textColor="0xff000000";

        layout_marginLeft="15dp";

        layout_marginTop="7dp";

        textSize="20sp";

        text="留言板";

      };

    };

  };

  {

    ScrollView;

    layout_width="match_parent";

    layout_height="match_parent";

    verticalScrollBarEnabled=false;

    {

      LinearLayout;

      orientation="vertical";

      layout_width="match_parent";

      layout_height="match_parent";

      {

        LinearLayout;

        layout_height="match_parent";

        orientation="vertical";

        layout_marginBottom="20dp";

        layout_width="match_parent";

        gravity="center|bottom";

        {

          EditText;

          layout_width=1040;

          id="UserInput";

        };

        {

          CardView;

          layout_height="43dp";

          backgroundColor="0xFF009AFF";

          layout_width=1010;

          id="send";

          radius="6dp";

          {

            LinearLayout;

            layout_height="match_parent";

            layout_width="match_parent";

            gravity="center";

            {

              TextView;

              textColor="0xff000000";

              text="发送";

            };

          };

        };

      };

      {

        ScrollView;

        layout_width="match_parent";

        verticalScrollBarEnabled=false;

        {

          LinearLayout;

          orientation="vertical";

          layout_width="match_parent";

          id="list";

        };

      };

    };

  };

};

cjson = import("cjson")


activity.setTitle("留言板")

activity.setContentView(loadlayout(layout))


function 控件圆角(控件,圆角,颜色)

  import "android.graphics.drawable.GradientDrawable"

  drawable = GradientDrawable()

  drawable.setShape(GradientDrawable.RECTANGLE)

  drawable.setColor(颜色)

  drawable.setCornerRadii({圆角,圆角,圆角,圆角,圆角,圆角,圆角,圆角})

  控件.setBackgroundDrawable(drawable)

end

控件圆角(send,20,0xFF009AFF)

function 水珠动画(view,time)

  import "android.animation.ObjectAnimator"

  ObjectAnimator().ofFloat(view,"scaleX",{1.2,.8,1.1,.9,1}).setDuration(time).start()

  ObjectAnimator().ofFloat(view,"scaleY",{1.2,.8,1.1,.9,1}).setDuration(time).start()

end

function 振动()

  --vibrator = activity.getSystemService(Context.VIBRATOR_SERVICE)

  --vibrator.vibrate( long{10,50} ,-1)

  --手册无法使用振动哦~

end

function csh()

  Http.get("http://szjlny.cn/lua/table.txt",nil,nil,nil,function(code,content)

    Table1 = cjson.decode(content)

    function 回复(tid)

      InputLayout={

        LinearLayout;

        orientation="vertical";

        Focusable=true,

        FocusableInTouchMode=true,

        {

          TextView;

          id="Prompt",

          textSize="15sp",

          layout_marginTop="10dp";

          layout_marginLeft="10dp",

          layout_marginRight="10dp",

          layout_width="match_parent";

          layout_gravity="center",

          text="输入:";

        };

        {

          EditText;

          hint="输入";

          layout_marginTop="5dp";

          layout_marginLeft="10dp",

          layout_marginRight="10dp",

          layout_width="match_parent";

          layout_gravity="center",

          id="edit";

        };

      };

      AlertDialog.Builder(this)

      .setTitle("")

      .setView(loadlayout(InputLayout))

      .setPositiveButton("确定",{onClick=function(v)

          if edit.Text ~="" then

            Http.get("http://szjlny.cn/lua/table.txt",nil,nil,nil,function(code,content)

              Table1 = cjson.decode(content)

              if Table1[tid].reply == "true" then

                c = #Table1[tid].ReplyData + 1

                Table1[tid].ReplyData[c]=edit.Text

               else

                Table1[tid].reply="true"

                Table1[tid].ReplyData={}

                Table1[tid].ReplyData[1]=edit.Text

              end

              Http.get("http://szjlny.cn/lua/table.php?table="..cjson.encode(Table1),nil,nil,nil,function()

                print("回复成功")

                activity.setContentView(loadlayout(layout))

                控件圆角(send,20,0xFF009AFF)

                csh()

              end)

            end)

           else

            print("不能为空")

          end

        end})

      .setNegativeButton("取消",nil)

      .show()

      import "android.view.View$OnFocusChangeListener"

      edit.setOnFocusChangeListener(OnFocusChangeListener{

        onFocusChange=function(v,hasFocus)

          if hasFocus then

            Prompt.setTextColor(0xFD009688)

          end

        end})

    end

    if Table1 then

      count = #Table1

      for i=#Table1,1,-1 do

        if Table1[count].reply == "true" then

          message_layout={

            LinearLayout;

            layout_width="fill";

            layout_height="fill";

            gravity="center";

            orientation="vertical";

            {

              CardView;

              layout_width=activity.getWidth()-60;

              layout_marginTop="10dp";

              alpha=0.9;

              radius="15dp";

              layout_marginBottom="4dp";

              onClick=function()回复(i) 振动()end;

              {

                LinearLayout;

                orientation="vertical";

                gravity="center|left";

                layout_width="fill";

                id="lllll";

                {

                  TextView;

                  text=Table1[count].content;

                  layout_marginLeft="10dp";

                  layout_marginTop="20dp";

                  layout_marginBottom="20dp";

                  textIsSelectable=true;

                  textColor="0xff000000";

                };

              };

            };

          };

          countz = #Table1[count].ReplyData

          list.addView(loadlayout(message_layout))

          for l=1,countz do

            replyLayout={

              LinearLayout;

              layout_width="fill";

              gravity="center";

              {

                CardView;

                layout_width=activity.getWidth()-105;

                alpha=0.3;

                layout_marginTop="3dp";

                layout_marginBottom="3dp";

                radius="15dp";

                {

                  TextView;

                  text="回复:"..Table1[count].ReplyData[l];

                  layout_marginLeft="10dp";

                  layout_marginTop="20dp";

                  layout_marginBottom="20dp";

                  textIsSelectable=true;

                  textColor="0xff000000";

                };

              };

            };

            list.addView(loadlayout(replyLayout))

          end

         else

          message_layout={

            LinearLayout;

            layout_width="fill";

            layout_height="fill";

            gravity="center";

            orientation="vertical";

            {

              CardView;

              layout_width=activity.getWidth()-60;

              layout_marginTop="10dp";

              alpha=0.9;

              id="dd";

              radius="15dp";

              layout_marginBottom="4dp";

              onClick=function()回复(i) 振动()end;

              {

                LinearLayout;

                orientation="vertical";

                gravity="center|left";

                layout_width="fill";

                {

                  TextView;

                  text=Table1[count].content;

                  layout_marginLeft="10dp";

                  layout_marginTop="20dp";

                  layout_marginBottom="20dp";

                  textIsSelectable=true;

                  textColor="0xff000000";

                };

              };

            };

          };

          list.addView(loadlayout(message_layout))

        end

        count = count - 1

        ---table[1].ReplyData[1]

      end

      function send.onClick()

        水珠动画(send,80)

        if UserInput.Text ~= "" then

          Http.get("http://szjlny.cn/lua/table.txt",nil,nil,nil,function(code,content)

            if Table1 == cjson.decode(content) then

              count1 = #Table1 + 1

              Table1[count1]={}

              Table1[count1].content=UserInput.Text

              Http.get("http://szjlny.cn/lua/table.php?table="..cjson.encode(Table1),nil,nil,nil,function(code,content) print(content) end)

              activity.setContentView(loadlayout(layout))

              csh()

             else

              Table1 = cjson.decode(content)

              count1 = #Table1 + 1

              Table1[count1]={}

              Table1[count1].content=UserInput.Text

              Http.get("http://szjlny.cn/lua/table.php?table="..cjson.encode(Table1),nil,nil,nil,function(code,content) print(content) end)

              activity.setContentView(loadlayout(layout))

              控件圆角(send,20,0xFF009AFF)

              csh()

            end

          end)

         else

          print("不能为空!")

        end

      end

    end

  end)

end

csh()

楼主签名:
回帖
回复列表
  • GS
    2023-02-28 20:14:22
    app很少有人装,还是简洁点,用着方便
    0 回复

遵守各国法律法规 严谨违规内容

  • QQ群:1140251126
  • Email:admin@admin.gs
  • 本站可以自由发布正规网站外链
  • 本站域名 admin.gs 其它皆为闲置域名
本站热帖
01 彩虹网站监控可以网址url监控,定时任务源码 628
02 携手特工、雷人组建了nice臻选 520
03 码支付漏洞测试开源版,来测试有没有漏洞 509
04 域名真的不行了,往年卖出去的又可以注册了 491
05 源支付V7版,以前150购买,需要的下载研究,拿走回复 409
06 免费收费域名 404
07 最新版弹幕播放器源码,带后台 396
08 我还有6个域名。 396
09 免费域名申请地址 354
10 扯谈域名投资 318
推荐主机