DataBinding not Updating TextView when notifyPropertyChanged(BR.xx) is used Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopWhen to use LinkedList over ArrayList in Java?How do I center text horizontally and vertically in a TextView?Making TextView scrollable on AndroidHow to display HTML in TextView?How do I make links in a TextView clickable?Auto Scale TextView Text to Fit within BoundsSet TextView style (bold or italic)How to change fontFamily of TextView in AndroidUpdate Eclipse with Android development tools v. 23

51k Euros annually for a family of 4 in Berlin: Is it enough?

Understanding Ceva's Theorem

Is it true that "carbohydrates are of no use for the basal metabolic need"?

Gordon Ramsay Pudding Recipe

Is the Standard Deduction better than Itemized when both are the same amount?

What is Arya's weapon design?

Book where humans were engineered with genes from animal species to survive hostile planets

How does debian/ubuntu knows a package has a updated version

How to tell that you are a giant?

Seeking colloquialism for “just because”

Single word antonym of "flightless"

What does the "x" in "x86" represent?

Why is "Consequences inflicted." not a sentence?

What is known about the Ubaid lizard-people figurines?

Can a non-EU citizen traveling with me come with me through the EU passport line?

Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?

Using audio cues to encourage good posture

Generate an RGB colour grid

Using et al. for a last / senior author rather than for a first author

Why didn't this character "real die" when they blew their stack out in Altered Carbon?

Do I really need recursive chmod to restrict access to a folder?

English words in a non-english sci-fi novel

Dating a Former Employee

Should I discuss the type of campaign with my players?



DataBinding not Updating TextView when notifyPropertyChanged(BR.xx) is used



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!Iterating through a Collection, avoiding ConcurrentModificationException when removing objects in a loopWhen to use LinkedList over ArrayList in Java?How do I center text horizontally and vertically in a TextView?Making TextView scrollable on AndroidHow to display HTML in TextView?How do I make links in a TextView clickable?Auto Scale TextView Text to Fit within BoundsSet TextView style (bold or italic)How to change fontFamily of TextView in AndroidUpdate Eclipse with Android development tools v. 23



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















I have a working dataBinding for the functions being called from XML (ie."@user.mUCL"). But When i use notifyPropertyChanged(BR.mUCL) in any method or anywhere New values dont get updated, I have provided a sample issue below, where for-loop updated Text1 with values, but other Text2 fails to update with the same values "not-worked".



JavaFragment



 public class FragmentTwo extends Fragment 

Update_observable updateObservable;
TextView fragment_quote_open_val;

public FragmentTwo()
// Required empty public constructor


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
// Inflate the layout for this fragment

Fragment2Binding fragmentTwoBinding = DataBindingUtil.inflate(inflater,R.layout.fragment2,null,false);
View view = fragmentTwoBinding.getRoot();
updateObservable = new Update_observable();
fragmentTwoBinding.setUser(updateObservable);

fragment_quote_open_val=(TextView)view.findViewById(R.id.fragment_quote_open_val);

bindingLoop();

return view;


@BindingAdapter("mUCL")
public static void runMe(TextView view, String message)
if (message != null)
view.setText(message);



public void bindingLoop()

final int[] k = 0;

final Update_observable ss=new Update_observable();

final Handler handler = new Handler();
final int delay = 3000; //milliseconds

handler.postDelayed(new Runnable()
public void run()
//do something
k[0]++;
fragment_quote_open_val.setText(String.valueOf(k[0]));
ss.setmUCL(String.valueOf(k[0]));

handler.postDelayed(this, delay);

, delay);




BaseObservable



 public class Update_observable extends BaseObservable 

public String mUCL= "not-worked";

@Bindable
public String getmUCL()
return this.mUCL;


public void setmUCL(String mUCL)
this.mUCL = mUCL;
notifyPropertyChanged(BR.mUCL);





XML



<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:bind="http://schemas.android.com/apk/res-auto">

<data>

<variable
name="user"
type="com.journaldev.androidmvvmbasics.fragments.Update_observable"/>

</data>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00ff04"
android:orientation="vertical"
android:gravity="center"
tools:context="com.journaldev.androidmvvmbasics.fragments.FragmentTwo">

<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/fragment_quote_open_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:textColor="#000000"
android:textSize="16dp" />
<TextView
android:id="@+id/fragment_quote_ucl_val"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@user.mUCL"
android:layout_margin="20dp"
bind:mUCL="@user.mUCL"
android:textColor="#000000"
android:textSize="16dp" />
</LinearLayout>

</layout>









share|improve this question






























    2















    I have a working dataBinding for the functions being called from XML (ie."@user.mUCL"). But When i use notifyPropertyChanged(BR.mUCL) in any method or anywhere New values dont get updated, I have provided a sample issue below, where for-loop updated Text1 with values, but other Text2 fails to update with the same values "not-worked".



    JavaFragment



     public class FragmentTwo extends Fragment 

    Update_observable updateObservable;
    TextView fragment_quote_open_val;

    public FragmentTwo()
    // Required empty public constructor


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
    Bundle savedInstanceState)
    // Inflate the layout for this fragment

    Fragment2Binding fragmentTwoBinding = DataBindingUtil.inflate(inflater,R.layout.fragment2,null,false);
    View view = fragmentTwoBinding.getRoot();
    updateObservable = new Update_observable();
    fragmentTwoBinding.setUser(updateObservable);

    fragment_quote_open_val=(TextView)view.findViewById(R.id.fragment_quote_open_val);

    bindingLoop();

    return view;


    @BindingAdapter("mUCL")
    public static void runMe(TextView view, String message)
    if (message != null)
    view.setText(message);



    public void bindingLoop()

    final int[] k = 0;

    final Update_observable ss=new Update_observable();

    final Handler handler = new Handler();
    final int delay = 3000; //milliseconds

    handler.postDelayed(new Runnable()
    public void run()
    //do something
    k[0]++;
    fragment_quote_open_val.setText(String.valueOf(k[0]));
    ss.setmUCL(String.valueOf(k[0]));

    handler.postDelayed(this, delay);

    , delay);




    BaseObservable



     public class Update_observable extends BaseObservable 

    public String mUCL= "not-worked";

    @Bindable
    public String getmUCL()
    return this.mUCL;


    public void setmUCL(String mUCL)
    this.mUCL = mUCL;
    notifyPropertyChanged(BR.mUCL);





    XML



    <layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:bind="http://schemas.android.com/apk/res-auto">

    <data>

    <variable
    name="user"
    type="com.journaldev.androidmvvmbasics.fragments.Update_observable"/>

    </data>


    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#00ff04"
    android:orientation="vertical"
    android:gravity="center"
    tools:context="com.journaldev.androidmvvmbasics.fragments.FragmentTwo">

    <!-- TODO: Update blank fragment layout -->
    <TextView
    android:id="@+id/fragment_quote_open_val"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_margin="20dp"
    android:textColor="#000000"
    android:textSize="16dp" />
    <TextView
    android:id="@+id/fragment_quote_ucl_val"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@user.mUCL"
    android:layout_margin="20dp"
    bind:mUCL="@user.mUCL"
    android:textColor="#000000"
    android:textSize="16dp" />
    </LinearLayout>

    </layout>









    share|improve this question


























      2












      2








      2


      1






      I have a working dataBinding for the functions being called from XML (ie."@user.mUCL"). But When i use notifyPropertyChanged(BR.mUCL) in any method or anywhere New values dont get updated, I have provided a sample issue below, where for-loop updated Text1 with values, but other Text2 fails to update with the same values "not-worked".



      JavaFragment



       public class FragmentTwo extends Fragment 

      Update_observable updateObservable;
      TextView fragment_quote_open_val;

      public FragmentTwo()
      // Required empty public constructor


      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState)
      // Inflate the layout for this fragment

      Fragment2Binding fragmentTwoBinding = DataBindingUtil.inflate(inflater,R.layout.fragment2,null,false);
      View view = fragmentTwoBinding.getRoot();
      updateObservable = new Update_observable();
      fragmentTwoBinding.setUser(updateObservable);

      fragment_quote_open_val=(TextView)view.findViewById(R.id.fragment_quote_open_val);

      bindingLoop();

      return view;


      @BindingAdapter("mUCL")
      public static void runMe(TextView view, String message)
      if (message != null)
      view.setText(message);



      public void bindingLoop()

      final int[] k = 0;

      final Update_observable ss=new Update_observable();

      final Handler handler = new Handler();
      final int delay = 3000; //milliseconds

      handler.postDelayed(new Runnable()
      public void run()
      //do something
      k[0]++;
      fragment_quote_open_val.setText(String.valueOf(k[0]));
      ss.setmUCL(String.valueOf(k[0]));

      handler.postDelayed(this, delay);

      , delay);




      BaseObservable



       public class Update_observable extends BaseObservable 

      public String mUCL= "not-worked";

      @Bindable
      public String getmUCL()
      return this.mUCL;


      public void setmUCL(String mUCL)
      this.mUCL = mUCL;
      notifyPropertyChanged(BR.mUCL);





      XML



      <layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:bind="http://schemas.android.com/apk/res-auto">

      <data>

      <variable
      name="user"
      type="com.journaldev.androidmvvmbasics.fragments.Update_observable"/>

      </data>


      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#00ff04"
      android:orientation="vertical"
      android:gravity="center"
      tools:context="com.journaldev.androidmvvmbasics.fragments.FragmentTwo">

      <!-- TODO: Update blank fragment layout -->
      <TextView
      android:id="@+id/fragment_quote_open_val"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="20dp"
      android:textColor="#000000"
      android:textSize="16dp" />
      <TextView
      android:id="@+id/fragment_quote_ucl_val"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@user.mUCL"
      android:layout_margin="20dp"
      bind:mUCL="@user.mUCL"
      android:textColor="#000000"
      android:textSize="16dp" />
      </LinearLayout>

      </layout>









      share|improve this question
















      I have a working dataBinding for the functions being called from XML (ie."@user.mUCL"). But When i use notifyPropertyChanged(BR.mUCL) in any method or anywhere New values dont get updated, I have provided a sample issue below, where for-loop updated Text1 with values, but other Text2 fails to update with the same values "not-worked".



      JavaFragment



       public class FragmentTwo extends Fragment 

      Update_observable updateObservable;
      TextView fragment_quote_open_val;

      public FragmentTwo()
      // Required empty public constructor


      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState)
      // Inflate the layout for this fragment

      Fragment2Binding fragmentTwoBinding = DataBindingUtil.inflate(inflater,R.layout.fragment2,null,false);
      View view = fragmentTwoBinding.getRoot();
      updateObservable = new Update_observable();
      fragmentTwoBinding.setUser(updateObservable);

      fragment_quote_open_val=(TextView)view.findViewById(R.id.fragment_quote_open_val);

      bindingLoop();

      return view;


      @BindingAdapter("mUCL")
      public static void runMe(TextView view, String message)
      if (message != null)
      view.setText(message);



      public void bindingLoop()

      final int[] k = 0;

      final Update_observable ss=new Update_observable();

      final Handler handler = new Handler();
      final int delay = 3000; //milliseconds

      handler.postDelayed(new Runnable()
      public void run()
      //do something
      k[0]++;
      fragment_quote_open_val.setText(String.valueOf(k[0]));
      ss.setmUCL(String.valueOf(k[0]));

      handler.postDelayed(this, delay);

      , delay);




      BaseObservable



       public class Update_observable extends BaseObservable 

      public String mUCL= "not-worked";

      @Bindable
      public String getmUCL()
      return this.mUCL;


      public void setmUCL(String mUCL)
      this.mUCL = mUCL;
      notifyPropertyChanged(BR.mUCL);





      XML



      <layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      xmlns:bind="http://schemas.android.com/apk/res-auto">

      <data>

      <variable
      name="user"
      type="com.journaldev.androidmvvmbasics.fragments.Update_observable"/>

      </data>


      <LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="#00ff04"
      android:orientation="vertical"
      android:gravity="center"
      tools:context="com.journaldev.androidmvvmbasics.fragments.FragmentTwo">

      <!-- TODO: Update blank fragment layout -->
      <TextView
      android:id="@+id/fragment_quote_open_val"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_margin="20dp"
      android:textColor="#000000"
      android:textSize="16dp" />
      <TextView
      android:id="@+id/fragment_quote_ucl_val"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@user.mUCL"
      android:layout_margin="20dp"
      bind:mUCL="@user.mUCL"
      android:textColor="#000000"
      android:textSize="16dp" />
      </LinearLayout>

      </layout>






      java android data-binding






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 12 '18 at 6:09







      Lazy Teddy

















      asked Dec 11 '18 at 13:17









      Lazy TeddyLazy Teddy

      939




      939






















          2 Answers
          2






          active

          oldest

          votes


















          0














          kindly make sure you do DataBindingUtil.inflate in Base class.



          Fragment1Binding fragmentOneBinding = DataBindingUtil.inflate(inflater,R.layout.fragment1,null,false);
          View view = fragmentOneBinding.getRoot();
          fragmentOneBinding.setUsermodel(new UserModel("XXXX","XXXX"));


          or



           ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, 
          R.layout.activity_main);
          activityMainBinding.setUser(new User());
          activityMainBinding.executePendingBindings();


          then in BaseObservable class do



          @Bindable
          public String mEmail= "....";


          rebuild project, just to make sure @Bindable is done for sure



          now call, as per your requirement.



           notifyPropertyChanged(BR.xxx);





          share|improve this answer























          • thankyou khan....

            – Lazy Teddy
            Mar 22 at 9:07


















          0














          I managed to find an answer for this, As DataBinding cannot be done programmatically.



          public class Update_observable extends BaseObservable {

          public String mUCL= "worked";

          public Update_observable(String mUCL)
          this.mUCL=mUCL;




          Fragment



           public void bindingLoop()

          final int[] k = 0;


          final Handler handler = new Handler();
          final int delay = 3000; //milliseconds

          handler.postDelayed(new Runnable()
          public void run()
          //do something
          k[0]++;
          fragment_quote_open_val.setText(String.valueOf(k[0]));
          updateObservable = new Update_observable(String.valueOf(k[0]));
          fragmentTwoBinding.setUser(updateObservable);
          handler.postDelayed(this, delay);

          , delay);






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53724987%2fdatabinding-not-updating-textview-when-notifypropertychangedbr-xx-is-used%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            kindly make sure you do DataBindingUtil.inflate in Base class.



            Fragment1Binding fragmentOneBinding = DataBindingUtil.inflate(inflater,R.layout.fragment1,null,false);
            View view = fragmentOneBinding.getRoot();
            fragmentOneBinding.setUsermodel(new UserModel("XXXX","XXXX"));


            or



             ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, 
            R.layout.activity_main);
            activityMainBinding.setUser(new User());
            activityMainBinding.executePendingBindings();


            then in BaseObservable class do



            @Bindable
            public String mEmail= "....";


            rebuild project, just to make sure @Bindable is done for sure



            now call, as per your requirement.



             notifyPropertyChanged(BR.xxx);





            share|improve this answer























            • thankyou khan....

              – Lazy Teddy
              Mar 22 at 9:07















            0














            kindly make sure you do DataBindingUtil.inflate in Base class.



            Fragment1Binding fragmentOneBinding = DataBindingUtil.inflate(inflater,R.layout.fragment1,null,false);
            View view = fragmentOneBinding.getRoot();
            fragmentOneBinding.setUsermodel(new UserModel("XXXX","XXXX"));


            or



             ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, 
            R.layout.activity_main);
            activityMainBinding.setUser(new User());
            activityMainBinding.executePendingBindings();


            then in BaseObservable class do



            @Bindable
            public String mEmail= "....";


            rebuild project, just to make sure @Bindable is done for sure



            now call, as per your requirement.



             notifyPropertyChanged(BR.xxx);





            share|improve this answer























            • thankyou khan....

              – Lazy Teddy
              Mar 22 at 9:07













            0












            0








            0







            kindly make sure you do DataBindingUtil.inflate in Base class.



            Fragment1Binding fragmentOneBinding = DataBindingUtil.inflate(inflater,R.layout.fragment1,null,false);
            View view = fragmentOneBinding.getRoot();
            fragmentOneBinding.setUsermodel(new UserModel("XXXX","XXXX"));


            or



             ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, 
            R.layout.activity_main);
            activityMainBinding.setUser(new User());
            activityMainBinding.executePendingBindings();


            then in BaseObservable class do



            @Bindable
            public String mEmail= "....";


            rebuild project, just to make sure @Bindable is done for sure



            now call, as per your requirement.



             notifyPropertyChanged(BR.xxx);





            share|improve this answer













            kindly make sure you do DataBindingUtil.inflate in Base class.



            Fragment1Binding fragmentOneBinding = DataBindingUtil.inflate(inflater,R.layout.fragment1,null,false);
            View view = fragmentOneBinding.getRoot();
            fragmentOneBinding.setUsermodel(new UserModel("XXXX","XXXX"));


            or



             ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, 
            R.layout.activity_main);
            activityMainBinding.setUser(new User());
            activityMainBinding.executePendingBindings();


            then in BaseObservable class do



            @Bindable
            public String mEmail= "....";


            rebuild project, just to make sure @Bindable is done for sure



            now call, as per your requirement.



             notifyPropertyChanged(BR.xxx);






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 22 at 9:02









            Mind_ControlMind_Control

            557




            557












            • thankyou khan....

              – Lazy Teddy
              Mar 22 at 9:07

















            • thankyou khan....

              – Lazy Teddy
              Mar 22 at 9:07
















            thankyou khan....

            – Lazy Teddy
            Mar 22 at 9:07





            thankyou khan....

            – Lazy Teddy
            Mar 22 at 9:07













            0














            I managed to find an answer for this, As DataBinding cannot be done programmatically.



            public class Update_observable extends BaseObservable {

            public String mUCL= "worked";

            public Update_observable(String mUCL)
            this.mUCL=mUCL;




            Fragment



             public void bindingLoop()

            final int[] k = 0;


            final Handler handler = new Handler();
            final int delay = 3000; //milliseconds

            handler.postDelayed(new Runnable()
            public void run()
            //do something
            k[0]++;
            fragment_quote_open_val.setText(String.valueOf(k[0]));
            updateObservable = new Update_observable(String.valueOf(k[0]));
            fragmentTwoBinding.setUser(updateObservable);
            handler.postDelayed(this, delay);

            , delay);






            share|improve this answer



























              0














              I managed to find an answer for this, As DataBinding cannot be done programmatically.



              public class Update_observable extends BaseObservable {

              public String mUCL= "worked";

              public Update_observable(String mUCL)
              this.mUCL=mUCL;




              Fragment



               public void bindingLoop()

              final int[] k = 0;


              final Handler handler = new Handler();
              final int delay = 3000; //milliseconds

              handler.postDelayed(new Runnable()
              public void run()
              //do something
              k[0]++;
              fragment_quote_open_val.setText(String.valueOf(k[0]));
              updateObservable = new Update_observable(String.valueOf(k[0]));
              fragmentTwoBinding.setUser(updateObservable);
              handler.postDelayed(this, delay);

              , delay);






              share|improve this answer

























                0












                0








                0







                I managed to find an answer for this, As DataBinding cannot be done programmatically.



                public class Update_observable extends BaseObservable {

                public String mUCL= "worked";

                public Update_observable(String mUCL)
                this.mUCL=mUCL;




                Fragment



                 public void bindingLoop()

                final int[] k = 0;


                final Handler handler = new Handler();
                final int delay = 3000; //milliseconds

                handler.postDelayed(new Runnable()
                public void run()
                //do something
                k[0]++;
                fragment_quote_open_val.setText(String.valueOf(k[0]));
                updateObservable = new Update_observable(String.valueOf(k[0]));
                fragmentTwoBinding.setUser(updateObservable);
                handler.postDelayed(this, delay);

                , delay);






                share|improve this answer













                I managed to find an answer for this, As DataBinding cannot be done programmatically.



                public class Update_observable extends BaseObservable {

                public String mUCL= "worked";

                public Update_observable(String mUCL)
                this.mUCL=mUCL;




                Fragment



                 public void bindingLoop()

                final int[] k = 0;


                final Handler handler = new Handler();
                final int delay = 3000; //milliseconds

                handler.postDelayed(new Runnable()
                public void run()
                //do something
                k[0]++;
                fragment_quote_open_val.setText(String.valueOf(k[0]));
                updateObservable = new Update_observable(String.valueOf(k[0]));
                fragmentTwoBinding.setUser(updateObservable);
                handler.postDelayed(this, delay);

                , delay);







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 12 '18 at 7:26









                Lazy TeddyLazy Teddy

                939




                939



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53724987%2fdatabinding-not-updating-textview-when-notifypropertychangedbr-xx-is-used%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript