Created
May 23, 2012 02:23
-
-
Save levinotik/2772880 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyView(c: Context) extends RelativeLayout(c) { | |
import AndroidConversions._; | |
val tv = new TextView(c) | |
var params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) | |
params.addRule(RelativeLayout.CENTER_IN_PARENT) | |
tv.setLayoutParams(params) | |
tv.setText("hello") | |
tv.setId(10) | |
addView(tv) | |
val b = new Button(c) | |
params = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, | |
ViewGroup.LayoutParams.WRAP_CONTENT) | |
params.addRule(RelativeLayout.BELOW, 10) | |
b.setLayoutParams(params) | |
b.setText("click me!") | |
b.onClick = {Toast.makeText(this, "You have clicked the button", Toast.LENGTH_LONG).show()} | |
addView(b) | |
} | |
[error] /Users/levinotik/Google Drive/code/Projects/scala/MyAndroidAppProject/src/com/example/myandroid/MyAndroidAppActivity.scala:41: value onClick is not a member of android.widget.Button | |
[error] b.onClick = {Toast.makeText(this, "You have clicked the button", Toast.LENGTH_LONG).show()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment