0

I have MainActivity and Another class which is in my SlideTabLayout and that class is a Fragment activity. And I have a button in the fragment activity, But when I try to update the text from MainActivity its not updating the button text.

public static void toggleControlButton(Button button, String state) {
    controlButton.setCompoundDrawablesWithIntrinsicBounds(stopIcon,
                            null, null, null);
    controlButton.setText("Stop");
}

Any hints ?

Achayan
  • 5,720
  • 2
  • 39
  • 61
  • Are you passing data from one activity to another? – Apurva Nov 12 '15 at 05:56
  • Yeah right I am passing data from FragmentActivity to MainActivity – Achayan Nov 12 '15 at 05:59
  • use interface to communicate between your activity and fragment, you can't directly changes UI from out of context – Pankaj Nimgade Nov 12 '15 at 06:04
  • Hmmm I am new to android dev and not sure how to do this. Do you have example if you dont mind ? – Achayan Nov 12 '15 at 06:14
  • let me get this right, you do some action in your fragment and then your fragment sends some information to the MainActivity. and you have a Button in context of MainActivity which you want to toggle? – Pankaj Nimgade Nov 12 '15 at 06:18
  • Almost but MainActivity don't have any button actually the button is in the fragment. I am trying to change fragment->button text from MainActivity – Achayan Nov 12 '15 at 06:27
  • you try this http://stackoverflow.com/questions/24927210/assign-data-to-activity-variable-from-fragment-and-get-variable-in-another-frag?rq=1 – PLP Nov 12 '15 at 06:33

0 Answers0