View Binding ਅਤੇ Data Binding Android ਵਿਸ਼ੇਸ਼ਤਾਵਾਂ ਹਨ ਜੋ ਪੁਰਾਣੇ findViewById ਤੋਂ ਵੱਧ ਸੁਰੱਖਿਅਤ ਅਤੇ ਸੁਵਿਧਾਜਨਕ ਤਰੀਕੇ ਨਾਲ XML ਲੇਆਉਟਸ ਵਿੱਚ ਕੋਡ ਨੂੰ ਵਿਊ ਨਾਲ ਜੋੜਦੀਆਂ ਹਨ। View Binding ਕਿਸਮ-ਸੁਰੱਖਿਅਤ ਵਿਊ ਹਵਾਲੇ ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ; Data Binding ਵਾਧੂ ਤੌਰ ਤੇ ਡੇਟਾ ਨੂੰ ਸਿੱਧਾ ਲੇਆਉਟਸ ਨਾਲ ਬੰਧਦਾ ਹੈ।
ਸਮੱਸਿਆ: findViewById
The old way: findViewById to get view references:
val button = findViewById<Button>(R.id.myButton)
✗ verbose; NOT type-safe (cast errors); NOT null-safe (wrong id → null → crash at runtime)
→ View/Data Binding solve these.
