add Hello android sample (similar to ios/Hello sample)

This commit is contained in:
Laurent Sansonetti
2014-04-24 14:53:57 +02:00
parent 8ca190645a
commit f63d8645c4
3 changed files with 49 additions and 0 deletions

13
android-samples/Hello/.gitignore vendored Normal file
View File

@@ -0,0 +1,13 @@
.repl_history
build
tags
.DS_Store
nbproject
.redcar
#*#
*~
*.sw[po]
.eprj
.sass-cache
.idea
.dat*.*

View File

@@ -0,0 +1,11 @@
# -*- coding: utf-8 -*-
$:.unshift("../../lib")
require 'motion/project/template/android'
Motion::Project::App.setup do |app|
# Use `rake config' to see complete project settings.
app.name = 'Hello'
app.api_version = '18'
app.sdk_path = File.expand_path('~/src/android-sdk-macosx')
app.ndk_path = File.expand_path('~/src/android-ndk-r9d')
end

View File

@@ -0,0 +1,25 @@
class MainActivity < Android::App::Activity
def onCreate(savedInstanceState)
super
@text = Android::Widget::TextView.new(self)
@text.text = 'Hello RubyMotion!'
@text.textColor = Android::Graphics::Color::WHITE
@text.textSize = 40.0
self.contentView = @text
end
def dispatchTouchEvent(event)
@counter ||= 0
case event.getAction
when Android::View::MotionEvent::ACTION_UP
@counter += 1
@text.text = "Touched #{@counter} times!"
@text.backgroundColor = Android::Graphics::Color::BLACK
when Android::View::MotionEvent::ACTION_MOVE
@text.text = "ZOMG!"
@text.backgroundColor = Android::Graphics::Color.rgb(rand(255), rand(255), rand(255))
end
true
end
end