making a varibal visibel for multipel files

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

making a varibal visibel for multipel files

Postby simondid » Fri Feb 18, 2011 10:33 pm

hey


so i goth this varibal witch i need to be editable/visibel from another file how can i due this??
simondid
Developer
Developer
 
Posts: 34
Joined: Mon Jan 31, 2011 3:45 pm

Top

Re: making a varibal visibel for multipel files

Postby imbroken » Sat Feb 19, 2011 8:57 am

is it enough to declare is public static?
imbroken
Senior Developer
Senior Developer
 
Posts: 131
Joined: Thu Jan 06, 2011 6:57 pm
Location: Germnay

Re: making a varibal visibel for multipel files

Postby simondid » Sat Feb 19, 2011 12:52 pm

i made it public static boolean radians = true; but i don't know who to find it in the othere file pleas help
simondid
Developer
Developer
 
Posts: 34
Joined: Mon Jan 31, 2011 3:45 pm

Re: making a varibal visibel for multipel files

Postby imbroken » Sat Feb 19, 2011 1:50 pm

If this variable is declared in MyClass.java you can use it like this from an other class: Myclass.radians = false;
imbroken
Senior Developer
Senior Developer
 
Posts: 131
Joined: Thu Jan 06, 2011 6:57 pm
Location: Germnay

Re: making a varibal visibel for multipel files

Postby simondid » Sat Feb 19, 2011 2:01 pm

ty it works

new problem i goth some radio button in one activity and in another i goth some button and a textview

so if the one radio button is pressed i wan't it to chance what the button dos but it's like the radio button dos not save the check i make pleas help me

so here is my code for the radio buttons
varibal hey is the one we care about

Code: Select all
@Override
   public void onCheckedChanged(RadioGroup group, int checkedId) {
      // TODO Auto-generated method stub
      switch (checkedId){
      case R.id.Virbration_OFF:
         Calculator.virbration = false;
         break;
      case R.id.Virbration_ON:
         Calculator.virbration = true;
         break;
      case R.id.Degrees:
         Calculator.Degrees = true;
         Calculator.hey = false;
         break;
      case R.id.Radians:
         Calculator.Radians = true;
         Calculator.hey = false;

         break;
            


and here is the code that check hey
Code: Select all
   if(virbration == true){
      Vibrator vibrator =(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.vibrate(50);
      input.append("1");
        if (hey == true){input.setText("hey1");}else if (hey == false){input.setText("hey2");}

      }else if (virbration == false){      input.append("1");
        if (hey == true){input.setText("hey1");}else if (hey == false){input.setText("hey2");}
}


hey is made with this code
Code: Select all
   public static boolean hey = true;



i dont see where the problem is
simondid
Developer
Developer
 
Posts: 34
Joined: Mon Jan 31, 2011 3:45 pm

Re: making a varibal visibel for multipel files

Postby strider2023 » Mon Feb 28, 2011 1:14 pm

I think this should be your approach for checking which radio button was checked by the user...

if(virbrationRadioButton.isChecked() == true){
Vibrator vibrator =(Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(50); ... etc etc
strider2023
Senior Developer
Senior Developer
 
Posts: 126
Joined: Tue Mar 02, 2010 6:34 am
Location: Chennai, India

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Google [Bot] and 12 guests