Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Pass values between activitys inner Tab

Pass values between activitys inner Tab

Put your problem here if it does not fit any of the other categories.

Pass values between activitys inner Tab

Postby hell0_android » Sun Feb 19, 2012 3:52 am

Hi all
Now I have a tabactivty is class A contain two tabs: tab1 have class B,tab2 have class C...
When run project tabactivity is display at tab1...In class B , i have a button1 to go to the class C...in class C i have a edittext and a button2...I want enter any text in edittext and click button to pass them to class B...
I have try any way:
In classB :
when click button1 I setcurrenttab(1) to go class C and in onCreate

Intent myIntent = new Intent();
myIntent = this.getIntent();
String value_receive = myIntent.getString("stringtext");
button1.setText(value_receive);

In class C:
when click button2 I set curretTab(0) to go class B and method onPaused of class C
@Override
public void onStop(){
Intent myIntent = new Intent();
myIntent.putExtra("stringtext", edittext.getText().toString());
this.setIntent(myIntent);
}

but when i run project button1 in class B not display text received from class C....

Can you help me to pass value between activity in tab....Thank for regard !
hell0_android
Freshman
Freshman
 
Posts: 9
Joined: Wed Sep 14, 2011 4:39 pm

Top

Re: Pass values between activitys inner Tab

Postby Phyll » Sun Feb 19, 2012 1:53 pm

Hi hello_android,

Here is a way to make variables that you don't need to "pass" from one activity to another in your app.

Create a class like this.

Code: Select all
public class GlobalVars extends Application {
   
    public String globalText = "Default";
   
}//application


Add this to your manifest in the application name: android:name=".GlobalVars" like this:

Code: Select all
Just an example

   <application android:name=".GlobalVars"
      android:icon="@drawable/and_icon"
      android:label="@string/app_name">

...

   </application>


Then add it to your activities (for each tab) like this:

Code: Select all
public class MyActivity extends Activity {

   private GlobalVars globalVars = null;   //Global context for applicaiton variables
                private String localText;

    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
       
        //get the application context and store it as our handle to the global variables
        globalVars = ((GlobalVars)getApplicationContext());
        localText = globalVars.globalText;


You can find more about application global variables on the internet. There are some obscure drawbacks. I also noticed that tabactivity has been deprecated so you may want to look into that. Global variables still cure a lot of problems sharing variables.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 9 guests