I just got AVD up and running, and I got a “HelloWorld” to work.
Now I figure the next logical step would be to get a bit more familar with I/O, so, I want to create and input box and have a button (or some sort of trigger) to hit when the person finishes input, and then to read it in, and output responses based on the input.
I’ve tried to use the Android Developers Resources, and it said that to create and input method, I needed to edit the AndroidManifest.xml and to add the service into it. So, my xml now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hunter.nance.escapetheroom"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".AndroidEscapeTheRoomActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name="FastInputIME"
android:label="@string/fast_input_label"
android:permission="android.permission.BIND_INPUT_METHOD">
<intent-filter>
<action android:name="android.view.InputMethod" />
</intent-filter>
<meta-data android:name="android.view.im" android:resource="@xml/method" />
</service>
</application>
However, my Eclipse file says error:
[2012-02-27 11:44:41 - com.android.ide.eclipse.adt.internal.project.AndroidManifestHelper] Unable to read C:\Documents and Settings\java\workspace\AndroidEscapeTheRoom\AndroidManifest.xml: org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system: '/AndroidEscapeTheRoom/AndroidManifest.xml'.
[2012-02-27 11:44:41 - AndroidEscapeTheRoom] AndroidManifest.xml does not declare a Java package: Build aborted.
Not to mention, even after getting the XML to work, I’m not sure how to utilize it in my actual Java code. Are there any good tutorials for this or any suggestions?
Thanks a lot!
You don’t need any permissions to put a textInput and manipulate it’s data. Open your layouts folder, then your Main xml file and go to design view. You can then drag and drop a text input. About the Java code, you go to your src folder, then in your package you’ll find one java file. To get a reference to your text input you’ll need something like this.
then you can get and set it’s text by using two methods:
try watching this: http://www.youtube.com/watch?v=0sS-ylTxi40
UPDATE:
This code will do exactly what you want. Just don’t forget to put the controls with same id-s in xml 🙂