添加文字到Android的UserDictionary文字、Android、UserDictionary

2023-09-12 04:12:36 作者:遍体鳞伤也要笑得猖狂

我要一个完整的医学词典添加到我的Andr​​oid手机(摩托罗拉的Droid)。我希望能够发短信,并有医疗话是在predictable文本。

I want to add an entire medical dictionary to my android phone (Moto Droid). I would like to be able to send text messages and have the medical words be in the predictable text.

我一直在试图写一个小的应用程序,将做到这一点,但一切我尝试启动应用程序崩溃。我从来没有写一个应用程序的移动平台,这是第一个我。这里是工作不正常。

I've been trying to write a small app that would accomplish this, but everything I try the app crashes on startup. I've never written an app for a mobile platform so that is a first for me. Here is what is not working properly.

public class WordAdd extends Activity {
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    UserDictionary.Words.addWord( this , "newMedicalWord", 1, UserDictionary.Words.LOCALE_TYPE_CURRENT);
}

}

这看起来很简单的事,但我很坚持。感谢您的帮助,您可以提供。

It seems so simple to do, yet I am so stuck. Thanks for any help you can provide.

编辑:我要指出,我收到此错误的Andr​​oid 2.1的AVD(虚拟设备)

I should mention that I am getting this error for Android 2.1 in the AVD (virtual device).

编辑2: 用户词典是在Android中API。 addWord 是一个静态方法。我不声明UserDictionary,因为我只使用一个静态方法。它已经老化,因为我用Java开发的东西,这是我在任何移动开发的第一次尝试,所以我不知道如果我做错了什么。

EDIT 2: User Dictionary is found in the Android API. addWord is a static method. I don't declare UserDictionary because I just use the one static method. It's been ages since I developed anything in Java and this is my first attempt at any mobile development, so I don't know if I am doing something wrong.

推荐答案

添加到您的应用程序的Andr​​oidManifest.xml文件的&LT之外;用途> 元素:

Add this to your app's AndroidManifest.xml file outside of the <application> element:

<uses-permission android:name="android.permission.WRITE_USER_DICTIONARY"></uses-permission>
 
精彩推荐
图片推荐