native TextField()
Monkey Targets Forums/Android/native TextField()| 
 | ||
| I want to give you a report about my test in displaying a native textfield gadget inside a monkey game. Perhaps someone can help me with the next step At the moment I am already able to display text without any loaded imagefont. I changed three files: ...\TestUI.build\android\templates\res\layout\main.xml <?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
	.....
	>
	
	<view class="${ANDROID_APP_PACKAGE}.MonkeyGame$GameView"
	.....
	/>
    <TextView  
		 android:id="@+id/textview1"
		 android:layout_width="fill_parent" 
		 android:layout_height="wrap_content" 
		 android:text="@string/hello"
		 android:textSize="30sp"
   />	    
</AbsoluteLayout>
together with: ...\TestUI.build\android\res\values\strings.xml <?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">This is a <u>text</u> feature You can display texts</string>
</resources>Both together will display a text on the screen in a completely basic monkey code: ...\TestUI.monkey Strict Import mojo Class Game Extends App Field Timer% Method OnCreate%() Return 0 End Method OnUpdate%() If KeyHit(KEY_ESCAPE) Then Error "" Return 0 End Method OnRender%() Return 0 End End Function Main%() New Game Return 0 End As a next step I want to change the visibility of this text. If I add this to the xml file hiding is already possible: ...\TestUI.build\android\templates\res\layout\main.xml <TextView  
     ...
     android:visibility="invisible"But now I want to make the visibility accessable from monkey code. And now this does not work. It produces an error, that the "package" is not known: ...\testUI.java class SystemPeter {
	public static float Test() {
		TextView MyView = (TextView) BBAndroidGame._androidGame._activity.findViewById( R.id.textview1 );
		MyView.setVisibility VISIBLE;
		return 123;
	}	
}...\TestUI.monkey Strict Import mojo Import "testUI.java" Extern #If TARGET="android" Function Test:Int()="SystemPeter.Test" #Endif Public Class Game Extends App Field Timer% Method OnCreate%() Return 0 End Method OnUpdate%() If KeyHit(KEY_ESCAPE) Then Error "" If TouchHit(0) Print "TouchHit !!!" + Test() Endif Return 0 End Method OnRender%() Return 0 End End Function Main%() New Game Return 0 End |