无法使用GWT存储来自Transliteration的值

时间:2014-04-28 11:46:00

标签: gwt

我是GWT的新手,我想创建一个应用程序,其中单词是音译并存储在varible中。它可用于在数据库中存储值。

但是当我尝试存储变量时,它会在打印时给出null值。

package com.google.gwt.language.sample.hellolanguage.client;

import java.util.ArrayList;
import java.util.List;
import com.google.gwt.language.client.transliteration.LanguageCode;
import com.google.gwt.language.client.transliteration.SupportedDestinationLanguages;
import com.google.gwt.language.client.transliteration.control.TransliterationControl;
import com.google.gwt.language.client.transliteration.control.TransliterationControlOptions;
import com.google.gwt.language.client.transliteration.text.Transliteration;
import com.google.gwt.language.client.transliteration.text.TransliterationCallback;
import com.google.gwt.language.client.transliteration.text.TransliterationResult;
import com.google.gwt.user.client.ui.Composite;





public class Trans extends Composite {


    ArrayList<String> wordsArray= new ArrayList<String>();
    public String sss;
    public void recieve(String ss)
    {
        this.sss=ss;
        System.out.println(sss);
    }


    public String send(){
         return sss;
    }

  public Trans(ArrayList<String> str) {


    initTransliterationControls(str);


//Here I want to print 
    System.out.println(sss);

  }

  public void initTransliterationControls(ArrayList<String> wordsArray1) {


    //ArrayList<String> wordsArray= new ArrayList<String>();
 //  wordsArray=wordsArray1;
    //System.out.println(wordsArray1.size());
   // for(int i=0;i<wordsArray1.size();i++)
    //{
        //wordsArray.add(wordsArray1.get(i).toString());
    //}
    wordsArray.add(wordsArray1.get(0).toString());
    wordsArray.add("Rerrebok");
    wordsArray.add("Woodland j_74_Hi-gh Heels Boots");


    //System.out.println(wordsArray);






    Transliteration.transliterate(wordsArray, LanguageCode.ENGLISH,
        LanguageCode.HINDI, new TransliterationCallback() {

          @Override
          public void onCallback(TransliterationResult result) {
             // System.out.println(result.getTransliterations().toString());
              List<List<String>> collection= new ArrayList<List<String>>();
            collection=result.getTransliterations();


// Here I am storing it on sss but when I am print outside this function it gives Null

            sss=collection.get(0).get(0).toString();


          }

    });

  }
}

0 个答案:

没有答案