Updated 3 February 2017
This is not best practice to add a view dynamic time through data binding, but if we want to add a view more time in more places then we can use to add view through Data Binding.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
public class CreateDynomicTextView { private Context mContext; private TextView textView; public CreateDynomicTextView(){} public CreateDynomicTextView(Context context){ mContext = context; } public void setTextView(){ textView = new TextView(mContext); } public TextView getTextView(){ textView = new TextView(mContext); textView.setText("hii added"); return textView; } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto" > <data> <variable name="createTV" type="com.webkul.mobikul_cs_cart.model.CreateDynomicTextView"/> </data> <LinearLayout android:id="@+id/add_ll" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" app:addDynomicView ="@{createTV.textView}" /> </layout> |
1 |
mainBinding.setCreateTV(new CreateDynomicTextView(getContext())); |
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
5 comments
What you facing the issue, please explain or share your code so that I can verify your point.