@@ -293,33 +293,53 @@ public void onSwipeStart(int position) {// swipe start
293
293
public void onSwipeEnd (int position ) {// swipe end
294
294
}
295
295
});
296
+ mListView .setOnItemLongClickListener (new AdapterView .OnItemLongClickListener () {
297
+ @ Override
298
+ public boolean onItemLongClick (AdapterView <?> parent , View view , int position , long id ) {
299
+ // 打开google translate
300
+ String word_string ="" ;
301
+ for (int i = 0 ; i < mEwordList .size (); i ++) {
302
+ if (i >=position -10 && i <=position +10 )
303
+ word_string +=mEwordList .get (i ).getWordSpell ()+".\n " ;
304
+ }
305
+ try {
306
+ Intent intent = new Intent ();
307
+ intent .setAction (Intent .ACTION_PROCESS_TEXT );
308
+ intent .setType ("text/plain" );
309
+ intent .putExtra (Intent .EXTRA_PROCESS_TEXT_READONLY , true );
310
+ intent .putExtra (Intent .EXTRA_PROCESS_TEXT , word_string );
311
+ startActivity (intent );
312
+ } catch (ActivityNotFoundException e ) {
313
+ // TODO Auto-generated catch block
314
+ Toast .makeText (getApplication (), "Sorry, No Google Translation Installed" ,
315
+ Toast .LENGTH_SHORT ).show ();
316
+ }
317
+
296
318
319
+
320
+ return false ;
321
+ }
322
+ });
297
323
mListView .setOnItemClickListener (new AdapterView .OnItemClickListener () {
298
324
299
325
@ Override
300
326
public void onItemClick (AdapterView <?> parent , View view , int position , long id ) {
301
- // TODO 自动生成的方法存根
302
- // try {
303
- //
304
- // Intent i = new Intent();
305
- // i.setAction(Intent.ACTION_VIEW);
306
- // i.putExtra("key_text_input", "hello");
307
- // i.putExtra("key_text_output", "");
308
- // i.putExtra("key_language_from", "en");
309
- // i.putExtra("key_language_to", "zh-CN");
310
- // //i.putExtra("key_suggest_translation", "");
311
- // //i.putExtra("key_from_floating_window", false);
312
- // i.setComponent(
313
- // new ComponentName(
314
- // "com.google.android.apps.translate",
315
- // "com.google.android.apps.translate.translation.TranslateActivity"));
316
- // startActivity(i);
317
- // } catch (ActivityNotFoundException e) {
318
- //
319
- // Toast.makeText(getApplication(),"Sorry, No Google Translation Installed",
320
- // Toast.LENGTH_SHORT).show();
321
- // }
322
- //bundle.putString("word", mEwordList.get(position).getspelling());
327
+
328
+ String word_string =mEwordList .get (position ).getWordSpell ();
329
+ try {
330
+ Intent intent = new Intent ();
331
+ intent .setAction (Intent .ACTION_PROCESS_TEXT );
332
+ intent .setType ("text/plain" );
333
+ intent .putExtra (Intent .EXTRA_PROCESS_TEXT_READONLY , true );
334
+ intent .putExtra (Intent .EXTRA_PROCESS_TEXT , word_string );
335
+ startActivity (intent );
336
+ } catch (ActivityNotFoundException e ) {
337
+ // TODO Auto-generated catch block
338
+ Toast .makeText (getApplication (), "Sorry, No Google Translation Installed" ,
339
+ Toast .LENGTH_SHORT ).show ();
340
+ }
341
+
342
+
323
343
ClipboardManager cm = (ClipboardManager ) getSystemService (Context .CLIPBOARD_SERVICE );
324
344
325
345
// 将文本内容放到系统剪贴板里。
0 commit comments