OnEditorActionListener

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

OnEditorActionListener

Postby gmad » Wed Jul 15, 2009 9:45 pm

I will be appreciate, if somebody will explain me, how to use OnEditorActionListener. Below I am attaching the fragment of method with mentioned in subject listener, but it doesn't work.
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. EditText input = new EditText(this);
  2.  
  3.     input.setOnEditorActionListener(new OnEditorActionListener() {
  4.  
  5.         public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
  6.  
  7.             AlertDialog.Builder build = new AlertDialog.Builder(context);
  8.  
  9.                 build.setIcon(R.drawable.warning)
  10.  
  11.                 .setMessage(R.string.communicate_3)
  12.  
  13.                 .setPositiveButton(R.string.bttn_ok, new DialogInterface.OnClickListener() {
  14.  
  15.                     public void onClick(DialogInterface dialog, int which) {
  16.  
  17.                         System.exit(0);
  18.  
  19.                     }
  20.  
  21.                 });
  22.  
  23.                 build.create();
  24.  
  25.                 build.show();
  26.  
  27.                 return true;
  28.  
  29.             }
  30.  
  31.         }
  32.  
  33.     });
Parsed in 0.032 seconds, using GeSHi 1.0.8.4
gmad
Freshman
Freshman
 
Posts: 4
Joined: Thu Jun 11, 2009 3:59 pm

Top

Postby Abhishek » Thu Jul 16, 2009 11:40 am

First of all its an Interface so you can,t create an object of interface......
Second...just implement it..and override its abstract method onEditorAction(,.....)

class A implement setOnEditorActionListener
{
input.setOnEditorActionListener(this);

public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
}
}
Abhishek
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Jun 23, 2009 10:07 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Majestic-12 [Bot] and 5 guests