ROSPDK / Sketchware-Pro

Sketchware Pro's sources in Java. Now anyone can contribute to Sketchware Pro.
https://sketchware.pro
Other
0 stars 0 forks source link

Add ViewBinding Support #6

Closed ROSPDK closed 2 months ago

ROSPDK commented 6 months ago

Is your feature request related to a problem? Please describe. ViewBinding is a feature that makes it easier to write code that interacts with views. Once view binding is enabled in a module, it generates a binding class for each XML layout file present in that module. An instance of a binding class contains direct references to all views that have an ID in the corresponding layout, but in feature updates.

Describe the solution you'd like Enabling ViewBinding will replace the findViewById methods with nothing, and private of any views variable are replace with private MainBinding variable is for MainActivity and you created any activity with expands xml name outside of .xml name, you generated the private [YOUR_XML_NAME_OUTSIDE_DOTXML_NAME_ONLY_ONE_LEFT_UPPERCASE]Binding variable.

Example: package [PACKAGE_NAME];

... import [PACKAGE_NAME].databinding.MainBinding;

public class MainActivity extends AppCompatActivity {

... private MainBinding binding;

@Override protected void onCreate(Bundle _savedInstanceState) { super.onCreate(_savedInstanceState); binding = MainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); } ...

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context or screenshots about the feature request here.