【lua教程】舔狗日记
require "import"import "android.app.*"
import "android.os.*"
import "android.widget.*"
import "android.view.*"
layout={
LinearLayout;
orientation="vertical";
layout_height="fill";
layout_width="fill";
{
LinearLayout;
orientation="vertical";
layout_width="match_parent";
backgroundColor="0xFFF2F2F2";
layout_weight="3";
layout_height="match_parent";
{
CardView;
layout_gravity="center";
layout_margin="30dp";
CardElevation="1";
backgroundColor="0xFFFFFFFF";
radius="15dp";
layout_width="match_parent";
layout_height="wrap_content";
{
LinearLayout;
orientation="vertical";
layout_height="match_parent";
layout_width="match_parent";
{
TextView;
id="舔狗日记";
layout_marginBottom="15dp";
gravity="center|top";
textColor="0xB2000000";
textSize="16sp";
layout_marginRight="20dp";
layout_weight="1";
layout_width="match_parent";
paddingTop="20dp";
text="舔狗日记";
layout_marginLeft="20dp";
layout_height="match_parent";
};
};
};
{
LinearLayout;
layout_height="match_parent";
gravity="center|top";
layout_width="match_parent";
{
Button;
id="刷新";
text="刷新";
layout_width="100dp";
layout_marginLeft="16dp";
textColor="0xFFFFFFFF";
};
{
Button;
layout_marginRight="8dp";
id="复制";
layout_width="100dp";
text="复制";
layout_marginLeft="8dp";
textColor="0xFFFFFFFF";
};
{
Button;
layout_marginRight="16dp";
id="转发";
layout_width="100dp";
text="转发";
textColor="0xFFFFFFFF";
};
};
};
};
activity.setTheme(android.R.style.Theme_DeviceDefault_Light)--设置md主题
activity.setTitle("舔狗日记")
activity.setContentView(loadlayout(layout))
activity.overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out)
import "android.graphics.drawable.ColorDrawable"
activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS).setStatusBarColor(0xFFF2F2F2);
activity.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
activity.ActionBar.hide()
function 控件圆角(view,InsideColor,radiu)
import "android.graphics.drawable.GradientDrawable"
drawable = GradientDrawable()
drawable.setShape(GradientDrawable.RECTANGLE)
drawable.setColor(InsideColor)
drawable.setCornerRadii({radiu,radiu,radiu,radiu,radiu,radiu,radiu,radiu});
view.setBackgroundDrawable(drawable)
end
function 复制内容到剪切板(内容)
import "android.content.*"
activity.getSystemService(Context.CLIPBOARD_SERVICE).setText(内容)
end
function 分享内容(内容)
import "android.content.*"
intent=Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "分享");
intent.putExtra(Intent.EXTRA_TEXT, 内容);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(Intent.createChooser(intent,"分享到:"));
end
控件圆角(刷新,0xAF000000,35)
控件圆角(复制,0xAF000000,35)
控件圆角(转发,0xAF000000,35)
刷新.onClick=function()
获取日记()
end
复制.onClick=function()
复制内容到剪切板(舔狗日记.text)
print("已复制到剪切板")
end
转发.onClick=function()
分享内容(舔狗日记.text)
end
cjson=import "cjson"
import "http"
--api来源于网络
function 获取日记()
Http.get("https://cloud.qqshabi.cn/api/tiangou/api.php",nil,"utf-8",nil,function(a,b,c,d)
if a==200
舔狗日记.setText(b)
end
end)
end
获取日记()
页:
[1]