Category : data-binding

My project was working perfectly fine but after changing my package name (different letters, not just capitalizing or decapitalizing) generated DataBinding files that always use the old package name import com.example.storage.`data`.PlantIndividual. My manifest files all contain the new package name and my app module gradle file also contains the correct applicationID I have tried this ..

Read more

why the RecyclerView scrolling is so laggy when i use Data binding??? Is that data-binding’s problem or Kotlin? class BleDeviceListAdapter(private val clickListener: BasicClickListener): RecyclerView.Adapter<BleDeviceListAdapter.BleDeviceListViewHolder>() { var taSystemList: MutableList<TASystem> = mutableListOf() override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = BleDeviceListViewHolder( DataBindingUtil.inflate( LayoutInflater.from(parent.context), R.layout.recycler_ble_item, parent, false ) ) override fun onBindViewHolder(holder: BleDeviceListViewHolder, position: Int) { val taSystem: TASystem ..

Read more

i am using databinding to change the color of the selected tab of tab layout @BindingAdapter(value = ["tabIndicatorColor", "context"]) fun setSelectedTabIndicatorColor(tabLayout: TabLayout, color: Int, context: Context) { tabLayout.setSelectedTabIndicatorColor(getColor(context, color)) } and setting it from the tabLayout view <variable name="professionalTypeColor" type="Integer" /> <com.google.android.material.tabs.TabLayout android:id="@+id/tl_images" android:layout_width="0dp" android:layout_height="5dp" tabIndicatorColor="@{professionalTypeColor}" context="@{context}" app:tabPaddingEnd="8dp" app:tabPaddingStart="8dp" /> what i did until here ..

Read more

I am trying to use InverseMethod for two-way binding. In the layout file, I have TextInputEditText <com.google.android.material.textfield.TextInputEditText android:id="@+id/edit_text_add_transaction_fee_income_tax" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@={Converter.convertToString(viewModel.feeIncomeTaxPercentage)}" android:inputType="numberDecimal"/> I defined my InverseMethod inside the Converter object object Converter { @JvmStatic @BindingConversion @InverseMethod("convertToDouble") public fun convertToString(d: Double?): String { return d?.toString() ?: "" } @JvmStatic @BindingConversion public fun convertToDouble(d: String?): Double? { ..

Read more

I want to set text using binding adapter.Here is the MyBindingAdapter.kt @BindingAdapter("android:setTitle") fun setTitle(textView : TextView,text: String){ textView.text = text } in activity_table.xml I used setTitle like this <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_column="1" android:layout_weight="1" android:gravity="center" android:setTitle="Hello word"/> and I getting below error in compile time Source: Android..

Read more

I’m trying to use Dagger hilt in my project. I have an Activity that uses Databinding: @AndroidEntryPoint class MainActivity : AppCompatActivity(), SetGreeting { private lateinit var binding: ActivityMainBinding @Inject lateinit var fragmentFactory: FragmentsFactory override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_main) supportFragmentManager.fragmentFactory = fragmentFactory … } override fun greeting(msg: String) { binding.greeting.text = ..

Read more

I want to setup my viewpager with tablelayout in fragment fragment: class HomeFragment : Fragment() { lateinit var bindingFragment: FragmentHomeBinding override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View { // Inflate the layout for this fragment bindingFragment = DataBindingUtil.inflate(inflater, R.layout.fragment_home, container, false) return bindingFragment.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { ..

Read more