After JavaFX, where elements of the window can be obtained using magic, attaching fields in the controller class (activate Android) with annotation, for example,

@FXML ListView<String> ciList; //название поля должно совпасть с ID компонента 

In the anroid, you have to look for a view every time like this:

 TextView twBurnTime = (TextView) findViewById(R.id.tw_burn_time); 

Another disadvantage is that in FX there is one ID name in XML and in code, but here they are different, in XML you need to write as_in_html. Have you come up with another annotation that would help developers write less and work more?

  • one
    You can still recall the Data binding library - the implementation of the MVVM pattern in Android - pavlofff
  • C using AndroidAnnotation has a side effect - drop-down lists have ceased to be filled. E/dalvikvm: Could not find class 'android.widget.ThemedSpinnerAdapter', referenced from method android.support.v7.widget.AppCompatSpinner$DropDownAdapter.<init> - Eugene

2 answers 2

"View injection"

Android Annotations:

 @ViewById TextView tw_burn_time; 

Worked with ButterKnifer, Dagger2, but the example above seems more appropriate for what you want at the moment.

  • 2
    I knew that I was not the only one I wanted :) - Eugene

AndroidAnnotations Powerful stuff

Butterknife Bindite View

Icepick SaveInstanceState without pain

  • one
    Thank. This is great news! The first is what you need. There not only it is possible. - Eugene