level 9
nirenr
楼主
require "import"
import "android.widget.*"
import "android.view.*"
function newButton(n)
return {
Button,
text=n,
layout_width="fill",
layout_height="fill",
layout_weight=1,
}
end
function newLine(t)
local line={
LinearLayout,
layout_width="fill",
layout_height="fill",
layout_weight=1,
}
for k,v in ipairs(t) do
table.insert(line,newButton(v))
end
return line
end
layout={
LinearLayout,
orientation="vertical",
layout_width="fill",
layout_height="fill",
{TextView,
layout_width="fill",
layout_height="fill",
layout_weight=1,}
}
btn={
{"1","2","3","+"},
{"4","5","6","-"},
{"7","8","9","*"},
{"0",".","=","/"},
}
for k,v in ipairs(btn) do
table.insert(layout,newLine(v))
end
activity.setContentView(layout)
2016年01月14日 15点01分
1
import "android.widget.*"
import "android.view.*"
function newButton(n)
return {
Button,
text=n,
layout_width="fill",
layout_height="fill",
layout_weight=1,
}
end
function newLine(t)
local line={
LinearLayout,
layout_width="fill",
layout_height="fill",
layout_weight=1,
}
for k,v in ipairs(t) do
table.insert(line,newButton(v))
end
return line
end
layout={
LinearLayout,
orientation="vertical",
layout_width="fill",
layout_height="fill",
{TextView,
layout_width="fill",
layout_height="fill",
layout_weight=1,}
}
btn={
{"1","2","3","+"},
{"4","5","6","-"},
{"7","8","9","*"},
{"0",".","=","/"},
}
for k,v in ipairs(btn) do
table.insert(layout,newLine(v))
end
activity.setContentView(layout)