Declare Global Variable

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Declare Global Variable

Postby venkat » Mon Feb 04, 2008 12:32 pm

Hi plus minus,

Can you tell me how to declare Global variable?.

for Example,
i have 4 Activities and all activities have one common variable like Name.

sorry for my bad english? if you don't under stand what i am asking please let me know?
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Top

Postby plusminus » Mon Feb 04, 2008 12:39 pm

Hello venkat,

If I have some final values I prefer to store them in a public Interface. Sample from AndNav:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public interface Constants {
  2.  
  3.         /** Overall DebugTag for whole AndNav. */
  4.  
  5.         public final String DEBUGTAG = "ANDNAV_DEBUGTAG";
  6.  
  7.        
  8.  
  9.         /** Shall be used if only one SubActivity is closed.*/
  10.  
  11.         public final int SUBACTIVITY_RESULTCODE_UP_ONE_LEVEL = 0;
  12.  
  13.         /** Shall be used if a chain of SubActivities is to be closed.*/
  14.  
  15.         public final int SUBACTIVITY_RESULTCODE_CHAINCLOSE = SUBACTIVITY_RESULTCODE_UP_ONE_LEVEL + 1;
  16.  
  17.         /** Shall be used to go back one level in the dialog-process. */
  18.  
  19.         public final int SUBACTIVITY_RESULTCODE_SUCCESS = SUBACTIVITY_RESULTCODE_CHAINCLOSE + 1;
  20.  
  21. }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby venkat » Mon Feb 04, 2008 12:45 pm

thanks for your replay, can you elaborate me ? :( please...
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Postby plusminus » Mon Feb 04, 2008 12:57 pm

Hello venkat,

you want a closer description :?:
:? I don't know what to explain more :?

You create new Interface, define some finals in there and use them somewhere in other Activities, like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.                                 try{
  2.  
  3.                                         /* Parse the caption to an Integer. */
  4.  
  5.                                         int i = Integer.parseInt(theCaption);
  6.  
  7.                                         /* And append it to the zipCodeEditText. */
  8.  
  9.                                         SDZip.this.zipCodeEditText.getText().append("" + i);
  10.  
  11.                                 }catch(NumberFormatException nfe){
  12.  
  13.                                         Log.e(Constants.DEBUGTAG, "numberPadGrid-onItemClick", nfe);
  14.  
  15.                                 }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Let me know if I misunderstood you. :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby venkat » Mon Feb 04, 2008 1:02 pm

Thanks for your reply plusminus, i will try it today and let you know if i have any doubt.
thanks again :)
Regards,
Venkat.
venkat
Senior Developer
Senior Developer
 
Posts: 152
Joined: Tue Nov 27, 2007 5:42 am
Location: India

Top

Return to General

Who is online

Users browsing this forum: No registered users and 2 guests