-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Steven Zack edited this page Sep 29, 2018
·
6 revisions
- 1.Install Go
- 2.Install your favorite IDE for Go
- 3.Install Android Studio and Android SDK
- 4.Install Android NDK
- 5.Install Go Mobile
go get github.com/gofaith/faithdroid
Open file $GOPATH/src/github.com/gofaith/faithdroid/main.go
Rewrite it with following code
package faithdroid
func (a *MainActivity) OnCreate() {
LinearLayout(a).DeferShow().Size(-2, -2).Append(
TextView(a).SetId("text").Text("text view"),
Button(a).Size(-2, -1).Text("change text").OnClick(func() {
GetTextViewById("text").Text("text changed")
}))
}
Run command blow:
gomobile bind --target=android -o $GOPATH/src/github.com/gofaith/faithdroid/example-android-project/faithdroid/faithdroid.aar github.com/gofaith/faithdroid
Open this Android project with Android Studio :$GOPATH/src/github.com/gofaith/faithdroid/example-android-project
Then do the same things you do with Android Studio:
- 1.Build an .apk file
Click menu Build->Build Apk
- 2.Run
Click the button with "Run" icon