注册会员 登录
Project1 返回首页

hyrious https://rpg.blue/?293821 [收藏] [复制] [分享] [RSS] 喵喵喵喵喵

日志

ruboto_irb_android_api【鷹文恐惧症患者尽快退散

热度 2已有 358 次阅读2014-2-5 22:20 |个人分类:个人日记| 鷹文恐惧症

本文将讲述一个鷹文恐惧症患者如何【使用ruboto_irb调用android_api】嗯对~
乃需要准备的有:
一部安卓爪机 # 在下使用的版本是4.0.4
ruboto-core    # http://ruboto.org
            ruboto-irb      # 请到软件商店中自找
Android API Browser # 同上 这是一个手册一样的东西 连数据包一起要9mb的样子 随便你们装不装吧
这里介绍两种调用方式(请注意ruboto中不能出现中文):
1. Import 【示例全部来自预置脚本
#弹出拨电话界面并设置电话号码为123
import "android.content.Intent"
import "android.net.Uri"
intent = Intent.new(Intent::ACTION_VIEW)
intent.setData(Uri.parse("tel:123"))
$irb.startActivity(intent)
#提示框
import 'android.widget.Toast'
Toast.makeText($irb, "Hello Ruboto!", Toast::LENGTH_LONG).show
也许你们能从中看出什么,但是接下来就是主要内容了!【喂上面的跳过了吗
2. Require
craps.rb (by Daniel Jackoway) # 这一基本示例包含了:TextView(显示文字), :LinearLayout(线性布局控件), :Button(按钮), :ListView(显示列表), :EditText(编辑框) 
   # 关于各控件的说明欢淫大家百度【上面那个browser也可以查到【或者你懂鷹文可以去这里http://developer.android.com/guide/index.html
require 'ruboto/activity'
require 'ruboto/widget'
require 'ruboto/util/toast'
# 以上必填【噗 详细请到这里看https://github.com/ruboto/ruboto/tree/master/assets/src/ruboto
ruboto_import_widgets :TextView, :LinearLayout, :Button, :ListView, :EditText # 是一个类似import的方法,语法和attr什么的一样,需要什么控件就加什么
# 以下是基本结构
[code]class A
def on_create(bundle) # 这个方法名是必须的 实际脚本执行时调用这个方法绘制主界面
super
setTitle "Somewords"
set_content_view(
linear_layout(:orientation => :vertical){
linear_layout(:orientation => :horizontal){
text_view :text => "foo";text_view :text => "bar"
button :text => "buzz", :width => :wrap_content, :on_click_listener => (proc{do something})
}
}
)
end
def change_activity(str)
start_ruboto_activity :class_name => str
end
end[/code]
http://codepad.org/YHdNk3SZ ←或者看这个
如果有哪里写得不够请尽管@在下~~【私信也可
2

鸡蛋

鲜花

刚表态过的朋友 (2 人)

评论 (0 个评论)

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-4 20:30

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部