|
|
发表于
2022-6-25 21:30:07
来自手机
|
显示全部楼层
来自 重庆
kemomimi酱 发表于 2022-6-25 21:23
http://gchat.qpic.cn/gchatpic_new/0/530077417-0-大写MD5/0
我记得
我应该加了
检测字母小写
然后自动转大写功能的
好像是- local function generate(toastWhat)
- local t=zf.Text
- local zerstr=string.char(0x00)
- local upperstr=string.upper(t)
- local s=utf8.len(t)
- local a=0
- local b=1
- local t0=upperstr
- local t3=""
- local function change()
- for n=1,s,1 do
- t1=String(t).substring(a,b)
- t2=string.gsub(t0,"文本",t1)
- t3=t3..t2
- a=a+1
- b=b+1
复制代码
我之前还专门写过一个自动转大写的小工具- layout={
- LinearLayout;
- layout_height="fill";
- layout_width="fill";
- };
- require "import"
- import "android.app.*"
- import "android.os.*"
- import "android.widget.*"
- import "android.view.*"
- import "android.widget.LinearLayout"
- import "android.view.inputmethod.InputMethodManager"
- import "android.widget.Adapter"
- import "android.R"
- import "android.widget.TextView"
- import "android.widget.Button"
- import "com.androlua.LuaArrayAdapter"
- import "java.lang.String"
- import "android.widget.ScrollView"
- import "android.widget.CardView"
- import "android.widget.EditText"
- import "android.widget.Spinner"
- --Copyright© Ayaka_Ago. All Rights Reserved.
- activity.setTheme(android.R.style.Theme_DeviceDefault_Light)--设置md主题
- local 数据={"字母大小写转换"}
- local pz={TextView,padding="16dp",textColor=文字色,textSize="16dp",layout_width="fill"}
- local adapter=LuaArrayAdapter(this,pz,String(数据))
- local function generate(toastWhat)
- local t=zf.Text
- local zerstr=string.char(0x00)
- local upperstr=string.upper(t)
- local s=utf8.len(t)
- local a=0
- local b=1
- local t0=upperstr
- local t3=""
- local function change()
- for n=1,s,1 do
- t1=String(t).substring(a,b)
- t2=string.gsub(t0,"文本",t1)
- t3=t3..t2
- a=a+1
- b=b+1
- end
- end
- if t == "" then
- print("请先输入内容")
- zf.requestFocus()
- imm.toggleSoftInput(0,InputMethodManager.RESULT_SHOWN)
- else
- if txt=="字母大小写转换" then
- change()
- elseif txt=="文字" then
- end
- result.Text=t0
- if toastWhat then print(toastWhat) end
- --imm.hideSoftInputFromWindow(zf.getWindowToken(), 0)
- end
- end
- this.setContentView(loadlayout({
- LinearLayout,
- layout_width="fill",
- orientation="vertical",
- {
- TextView,
- paddingLeft="16dp",
- paddingRight="106dp",
- layout_height="52dp",
- textColor=图标色,
- gravity="center",
- text="文字处理",
- textSize="18dp",
- },
- {
- ScrollView,
- layout_width="fill",
- {
- LinearLayout,
- layout_width="fill",
- orientation="vertical",
- {
- CardView,
- layout_width="fill",
- radius="12dp",
- layout_margin="24dp",
- layout_marginBottom="16dp",
- layout_marginTop="16dp",
- {
- EditText,
- layout_width="fill",
- minLines=6,
- inputType="textMultiLine",
- id="zf",
- gravity="top",
- hint="输入要处理的文字",
- backgroundColor=0,
- textSize="16dp",
- padding="16dp",
- textColor=文字色,
- hintTextColor=次要文字色,
- },
- },
- {
- Spinner,
- layout_width="fill",
- id="xl",
- Adapter=adapter,
- onItemSelectedListener={
- onItemSelected=function(parent,view,position,id)
- txt=view.Text
- end},
- layout_margin="24dp",
- layout_marginTop=0,
- layout_marginBottom=0,
- },
- {
- LinearLayout,
- layout_gravity="center",
- {
- Button,
- text="生成",
- layout_weight=1,
- backgroundColor=0,
- textColor=0xff00b1ff,
- textSize="16dp",
- onClick=function() generate("已生成内容") end,
- },
- {
- Button,
- text="复制",
- layout_weight=1,
- backgroundColor=0,
- onClick=function ()
- if result.Text=="生成后的文字将会显示在此处" and #zf.Text < 1 then
- print"请先输入内容"
- zf.requestFocus()
- imm.toggleSoftInput(0,InputMethodManager.RESULT_SHOWN)
- elseif #zf.Text > 0 and result.Text=="生成后的文字将会显示在此处" then
- generate()
- copyText(result.Text)
- else
- copyText(result.Text)
- end
- end,
- textSize="16dp",
- textColor=0xff00b1ff,
- },
- {
- Button,
- text="分享",
- layout_weight=1,
- backgroundColor=0,
- textColor=0xff00b1ff,
- textSize="16dp",
- onClick=function()
- if #zf.Text > 0 and result.Text=="生成后的文字将会显示在此处" then
- generate()
- shareText(result.Text)
- elseif result.Text=="生成后的文字将会显示在此处" then
- print"请先输入内容"
- zf.requestFocus()
- imm.toggleSoftInput(0,InputMethodManager.RESULT_SHOWN)
- else
- shareText(result.Text)
- end
- end,
- },
- },
- {
- TextView,
- text="生成后的文字将会显示在此处",
- id="result",
- padding="36dp",
- textSize="16dp",
- layout_width="fill",
- textIsSelectable=true,
- textColor=文字色,
- },
- },
- },
- }))
复制代码 |
|