Wednesday, February 5, 2014

Questions about the expansion of EditText


            
An expansion of EditText of class, as

 public class test extends EditText {

public test (Context context, AttributeSet attrs)
{
super (context, attrs);
}

@ Override
public boolean onKeyPreIme (int keyCode, KeyEvent event)
{
if (event.getKeyCode () == android.view.KeyEvent.KEYCODE_BACK) {
/ / To do something
}
return super.onKeyPreIme (keyCode, event);
}
}


OnKeyPreIme which used to precede the soft keyboard input back to capture the key, ask the following:
1. How will this event here in onKeyPreIme submitted to cite this extension EditText class program, or trigger refers to this extended class program code;
2. Such classes can obtain a reference to the name of the class in this extension do? That is such a gallery.class cite this test.class, to get the name of the gallery test.class it?

Thank you!
Reply:
Dingding .............
Reply:
Dingding. . . .
Reply:
Dingding. . . .
        

Reply:
You constructor in context to come to pass, you can determine the context of the type
if (context instanceof gallery) {
Of course, you can get its class name
Reply:
references, 4th Floor cclovescw reply:
constructor where you come to pass context, you can determine the context of the type
if (context instanceof gallery) {
Of course, you can get its class name


Can detail under it? Thank you

No comments:

Post a Comment