0

I have Tab host contains Three tabs "STEP 1,STEP 2,and STEP 3". Main Tab Host Activity "MainActiveTab" is Parent activity ,child Activity "TabActStep_1,TabActStep_2,TabActStep_3 " resp.

I Want to access on EditText and Other Value from child Tab Activity like "TabActStep_1,TabActStep_2,TabActStep_3 " .

//Assign id to Tabhost.
        TabHostWindow = (TabHost) findViewById(android.R.id.tabhost);

        //Creating tab menu.
        TabHost.TabSpec TabMenu1 = TabHostWindow.newTabSpec("First tab");
        TabHost.TabSpec TabMenu2 = TabHostWindow.newTabSpec("Second Tab");
        TabHost.TabSpec TabMenu3 = TabHostWindow.newTabSpec("Third Tab");

        //Setting up tab 1 name.
        TabMenu1.setIndicator("STEP 1");
        //Set tab 1 activity to tab 1 menu.
        TabMenu1.setContent(new Intent(this, TabActStep_1.class));

        //Setting up tab 2 name.
        TabMenu2.setIndicator("STEP 2");
        //Set tab 3 activity to tab 1 menu.
        TabMenu2.setContent(new Intent(this, TabActStep_2.class));


        //Setting up tab 2 name.
        TabMenu3.setIndicator("STEP 3");
        //Set tab 3 activity to tab 3 menu.
        TabMenu3.setContent(new Intent(this, TabActStep_3.class));

    //Adding tab1, tab2, tab3 to tabhost view.

    TabHostWindow.addTab(TabMenu1);
    TabHostWindow.addTab(TabMenu2);
    TabHostWindow.addTab(TabMenu3);

This is "MainActiveTab" Here I Want To Get Child Tab Activity Values EditText. etc Am Try to Send Value from Child Tab Like This

   Intent intent = new Intent(getApplicationContext(), MainActiveTab.class);
   // Intent intent = new Intent(getApplicationContext(),MainActiveTab.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.putExtra("name","tab");
       // intent.putExtra("HouseName", strHouseName);
        startActivity(intent);

This passing Value Get From Main Tab in MainActiveTab Using This Code Using Here

Bundle bundle = getIntent().getExtras();
String id=bundle.get("name").toString();

Declaring intent function on child Tab the that Tab is Showing "Unfortunately App Has Stopped" I Hope You Can Help Me.Thank You !!!

basil
  • 21
  • 11
  • what is the issue? – sasikumar Nov 16 '16 at 05:49
  • i can't to get value from Child Tab. am declaring intent function on child Tab the that Tab is Showing "Unfortunately App Has Stopped" – basil Nov 16 '16 at 05:51
  • please stop using tabs with activities. They are deprecated about 5 years ago. Use fragments. Nobody remembers already how people million years ago worked with a stone axe as well as with Activities in tabs. – Vladyslav Matviienko Nov 16 '16 at 06:30

1 Answers1

0

You cannot directly send a value from Activity to a Fragment.You have use an interface to achieve that.

Fragment1->Interface->ActivityClass->Fragment2.

Rushi Ayyappa
  • 2,708
  • 2
  • 16
  • 32