"Instanciation" d'une interface ?
Bonjour,
Je lis dans la documentation officielle Android concernant l'objet Button (cf. le lien en bas de ce message) :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
public class MyActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_layout_id);
final Button button = findViewById(R.id.button_id);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Code here executes on main thread after user presses button
}
});
}
}
The above snippet creates an instance of View.OnClickListener and wires the listener to the button using setOnClickListener(View.OnClickListener) |
Si je vais dans cette même documentation sur View.OnClickListener, je trouve :
Code:
1 2 3
|
View.OnClickListener
public static interface View.OnClickListener |
Or - à moins que quelque-chose m'ait échappé - j'en suis resté au fait qu'une interface ne s'instanciait pas... 8O
Si quelqu'un pouvait éclairer ma lanterne, ce serait vraiment cool ! :D
Merci d'avance...
Source : https://developer.android.com/refere...et/Button.html:?