SharedPreferences ToggleButton not saving - android

*I've been going nuts with this problem the last few days.I'm trying to use SharedPreferences to allow my users to save the selected option of the in-game audio via the ToggleButton but everytime when I run my app and hit my "Done" button to go back to the main_activity screen and then click on settings again it never saves.I've done some research on this by googling,my book and this site but by many methods I've tried the result is the same.
I'm new to android development let alone app development so as much as I learned these past few weeks this has been a major roadblock for me and I apologize if this question has been covered already on this site but I'm at a real loss on what I'm doing wrong here.
Here is my code from my settings activity.
package com.fullfrontalgames.numberfighter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceManager;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ToggleButton;
public class Settings extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.settings);
Button Notifications = (Button) findViewById(R.id.Notifications);
Button Done = (Button) findViewById(R.id.done);
Button AccountSettings = (Button) findViewById(R.id.AccountSettings);
final ToggleButton AT = (ToggleButton) findViewById(R.id.AudioToggle);
AT.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
{
if ((AT.isChecked()))
{
SharedPreferences appPrefs =
getSharedPreferences("com.fullfrontalgames.numberfighter.Settings_preferences",
MODE_PRIVATE);
SharedPreferences.Editor editor = appPrefs.edit();
editor.putBoolean("atpref", AT.isChecked()); //value to store
editor.commit();
}
}
}
});
SharedPreferences appPrefs =
getSharedPreferences("com.fullfrontalgames.numberfighter.Settings_preferences",
MODE_PRIVATE);
boolean atpref = appPrefs.getBoolean("atpref", true); //default is true
AT.setChecked(atpref);
Done.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent Intent = new Intent(Settings.this,activity_main.class);
Intent.setFlags(android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(Intent);
}
});
Notifications.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fullfrontalgames.numberfighter.Notifications"));
}
});
AccountSettings.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.fullfrontalgames.numberfighter.AccountSettings"));
}
});
}
public void onToggleClicked(View view) {
// Is the toggle on?
boolean on = ((ToggleButton) view).isChecked();
if (on) {
view.setSoundEffectsEnabled(true);
} else {
view.setSoundEffectsEnabled(false);
}
}
}

If you are trying to save the ToggleButton's state when it is false, simply remove the if-statement in your OnClickListener:
if ((AT.isChecked()))

Related

Android : Save Button Instance

Hello i'm working on my android project. I have created an activity where the use gets four buttons, n i want the user to select any one. I have done this by setting other buttons to .setClickable(false). But when I restart or say relaunch the app again all the buttons get enabled. I want that when user selects a button it should save its choice, so that on retstart of app, the user doesn't get confused. Below is the piece of code:
Notifications.class
package com.mateoj.multiactivitydrawer;
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.NotificationCompat;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.mateoj.multiactivitydrawer.department.dept_1styeartab;
import com.pushbots.push.Pushbots;
public class notifications extends BaseActivity {
private WebView webView;
Button clickButton;
Button clickButton1;
Button clickButton2;
Button clickButton3;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Pushbots.sharedInstance().init(this);
Pushbots.sharedInstance().setCustomHandler(customHandler.class);
setContentView(R.layout.activity_notifications);
final SharedPreferences preferences = getSharedPreferences("com.mateoj.multiactivitydrawer", MODE_PRIVATE);
final SharedPreferences.Editor editor = preferences.edit();
clickButton = (Button) findViewById(R.id.ncs);
clickButton1 = (Button) findViewById(R.id.nmech);
clickButton2 = (Button) findViewById(R.id.nece);
clickButton3 = (Button) findViewById(R.id.neee);
clickButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_cse.class);
Pushbots.sharedInstance().tag("cse");
Pushbots.sharedInstance().untag("mech");
Pushbots.sharedInstance().untag("ece");
Pushbots.sharedInstance().untag("eee");
editor.putString("session", "cse").commit();
editor.commit();
startActivity(show);
}
});
clickButton1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_mech.class);
Pushbots.sharedInstance().tag("mech");
Pushbots.sharedInstance().untag("ece");
Pushbots.sharedInstance().untag("eee");
Pushbots.sharedInstance().untag("cse");
editor.putString("session", "mech").commit();
editor.commit();
startActivity(show);
}
});
clickButton2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_ece.class);
Pushbots.sharedInstance().tag("ece");
Pushbots.sharedInstance().untag("mech");
Pushbots.sharedInstance().untag("eee");
Pushbots.sharedInstance().untag("cse");
editor.putString("session", "ec").commit();
editor.commit();
startActivity(show);
}
});
clickButton3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_eee.class);
Pushbots.sharedInstance().tag("eee");
Pushbots.sharedInstance().untag("ece");
Pushbots.sharedInstance().untag("mech");
Pushbots.sharedInstance().untag("cse");
editor.putString("session", "eee").commit();
editor.commit();
startActivity(show);
}
});
onStartUp();
}
private void onStartUp()
{
SharedPreferences sharedPreferences = getSharedPreferences("com.mateoj.multiactivitydrawer", Context.MODE_PRIVATE);
String str = sharedPreferences.getString("session", "");
if (str.equals("cs")) {
clickButton.setClickable(true);
clickButton1.setClickable(false);
clickButton2.setClickable(false);
clickButton3.setClickable(false);
} else if (str.equals("mech")) {
clickButton.setClickable(false);
clickButton1.setClickable(true);
clickButton2.setClickable(false);
clickButton3.setClickable(false);
} else if (str.equals("ec")) {
clickButton.setClickable(false);
clickButton1.setClickable(false);
clickButton2.setClickable(true);
clickButton3.setClickable(false);
} else if (str.equals("eee")) {
clickButton.setClickable(false);
clickButton1.setClickable(false);
clickButton2.setClickable(false);
clickButton3.setClickable(true);
}
}
/* private class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
} */
#Override
protected boolean useDrawerToggle() {
return false;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_credits)
return true;
if (item.getItemId() == android.R.id.home)
onBackPressed();
return super.onOptionsItemSelected(item);
}
}
So what should be changed here
One thing you could do is save the state of the Button (Everytime you/user click on the Button save the true or false on your SharedPreferences) and everytime you start the Activity the value of setClickable() put the result of your SharedPrefernce.
That's an option, but there are a lot of ways to do it, that's one of them.
I don't know this framework that you are using (Pushbots), but I think you are forgeting to check which tag is saved in Pushbots during the activity method onCreate() and enable or disable the buttons according to it. You are saving the tags on Pushbots button you never check which tag is saved on it to enable or disable the button.
I'd recommend you to use SharedPreferences directly instead of use this framework, even I don't know it. SharedPreferences is so simple to use that I don't see any reason to use frameworks.
You can use the SharedPreferences class to save the user selection.This video can help you get started - https://www.youtube.com/watch?v=riyMQiHY3V4 .Just save the user selection of button in a key value pair with sharedpreferences class.On activity restart or relaunch just check for the value in the shared preferences instance and accordingly set the button setClickable(true) or setClickable(false).
EDIT:
clickButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
//same code as above without the setClickable() on buttons
//remove the button.setClickable(false); for rest of the buttons
editor.putString("session", "akash").commit();
editor.commit();
startActivity(show); //Start the activity here
}
}):
Repeat this for all the click listeners and change the "akash" to something different (according to need) for each button click listener.Then use the method
private void onStartUp(){
SharedPreferences sharedPreferences = getSharedPreferences("com.mateoj.multiactivitydrawer", Context.MODE_PRIVATE);
String str=sharedPreferences .getString("session","akash");
if(str.equals("akash")){
//set buttons setClickable(true) or setClickable(false)
} else if(str.equals("...")) //replace "..." with other strings which can replace "akash"
//set buttons setClickable(true) or setClickable(false)
} //continue the else if logic till all conditions are met
}
call onStartUp(); in onCreate(); after setting the on click listeners for the buttons .

Android : Choose Intent to open from Button

I'm working on android project. In my activity i have four buttons. The user has to select the particular button to receive the notifications. So the next time if i select Notifications(its a fragment of nav drawer) it should directly lead me to that particular activity instead of again selecting the department.
1st Run
Nav Drawer (select Notification)>>Opens Activity(to choose button to receive notification) >> Opens that particular activity
2nd Run
Nav Drawer(select Notification)>> Directly opens the selected activity
Notification.class
import android.app.Notification;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v7.app.NotificationCompat;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.mateoj.multiactivitydrawer.department.dept_1styeartab;
import com.pushbots.push.Pushbots;
public class notifications extends BaseActivity {
private WebView webView;
Button clickButton;
Button clickButton1;
Button clickButton2;
Button clickButton3;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Pushbots.sharedInstance().init(this);
Pushbots.sharedInstance().setCustomHandler(customHandler.class);
setContentView(R.layout.activity_notifications);
SharedPreferences preferences = getSharedPreferences("com.mateoj.multiactivitydrawer", MODE_PRIVATE);
final SharedPreferences.Editor editor = preferences.edit();
clickButton = (Button) findViewById(R.id.ncs);
clickButton1 = (Button) findViewById(R.id.nmech);
clickButton2 = (Button) findViewById(R.id.nece);
clickButton3 = (Button) findViewById(R.id.neee);
clickButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_cse.class);
Pushbots.sharedInstance().tag("cse");
Pushbots.sharedInstance().untag("mech");
Pushbots.sharedInstance().untag("ece");
Pushbots.sharedInstance().untag("eee");
editor.putString("session", "cse").commit();
editor.commit();
startActivity(show);
}
});
clickButton1.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_mech.class);
Pushbots.sharedInstance().tag("mech");
Pushbots.sharedInstance().untag("ece");
Pushbots.sharedInstance().untag("eee");
Pushbots.sharedInstance().untag("cse");
editor.putString("session", "mech").commit();
editor.commit();
startActivity(show);
}
});
clickButton2.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_ece.class);
Pushbots.sharedInstance().tag("ece");
Pushbots.sharedInstance().untag("mech");
Pushbots.sharedInstance().untag("eee");
Pushbots.sharedInstance().untag("cse");
editor.putString("session", "ec").commit();
editor.commit();
startActivity(show);
}
});
clickButton3.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent show = new Intent(getApplicationContext(), noti_eee.class);
Pushbots.sharedInstance().tag("eee");
Pushbots.sharedInstance().untag("ece");
Pushbots.sharedInstance().untag("mech");
Pushbots.sharedInstance().untag("cse");
editor.putString("session", "eee").commit();
editor.commit();
startActivity(show);
}
});
onStartUp();
}
#Override
protected void onDestroy() {
super.onDestroy();
onStartUp();
}
#Override
protected void onPause() {
super.onPause();
onStartUp();
}
#Override
protected void onStop() {
super.onStop();
onStartUp();
}
private void onStartUp()
{
SharedPreferences sharedPreferences = getSharedPreferences("com.mateoj.multiactivitydrawer", Context.MODE_PRIVATE);
String str = sharedPreferences.getString("session", "");
if (str.equals("cs")) {
clickButton.setClickable(true);
clickButton1.setClickable(false);
clickButton2.setClickable(false);
clickButton3.setClickable(false);
} else if (str.equals("mech")) {
clickButton.setClickable(false);
clickButton1.setClickable(true);
clickButton2.setClickable(false);
clickButton3.setClickable(false);
} else if (str.equals("ec")) {
clickButton.setClickable(false);
clickButton1.setClickable(false);
clickButton2.setClickable(true);
clickButton3.setClickable(false);
} else if (str.equals("eee"))
{
clickButton.setClickable(false);
clickButton1.setClickable(false);
clickButton2.setClickable(false);
clickButton3.setClickable(true);
}
}
/* private class MyWebViewClient extends WebViewClient {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
} */
#Override
protected boolean useDrawerToggle() {
return false;
}
#Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_credits)
return true;
if (item.getItemId() == android.R.id.home)
onBackPressed();
return super.onOptionsItemSelected(item);
}
}
The onStartup code saves the preferences

back button shows blank screen

When I press the 'back' button of a mobile-phone it shows me a blank page. When I again press the 'back' button it then shows me the main page of the application. I want to get to the mainActivity page on first back press.
mainActivity code:
import android.support.v7.app.ActionBarActivity;
import android.support.v7.app.ActionBar;
import android.support.v4.app.Fragment;
import android.text.style.SuperscriptSpan;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.os.Build;
public class MainActivity extends ActionBarActivity {
Button b1,b2,b3,b4,b5,b6,b7;
EditText e1;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.call1);
e1=(EditText)findViewById(R.id.call);
b1.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
String no=e1.getText().toString();
Intent call=new Intent(Intent.ACTION_CALL);
call.setData(Uri.parse("tel:"+no));
startActivity(call);
}
});
b2=(Button)findViewById(R.id.sens_sms);
b2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent sendsms=new
Intent(getApplicationContext(),waytosms.class);
startActivity(sendsms);
}
});
b3=(Button)findViewById(R.id.facebook);
b3.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent facebook=new Intent(MainActivity.this,facebook.class);
startActivity(facebook);
finish();
}
});
b4=(Button)findViewById(R.id.gmail);
b4.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent facebook=new Intent(MainActivity.this,gmail.class);
startActivity(facebook);
}
});
b5=(Button)findViewById(R.id.utube);
b5.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent facebook=new Intent(MainActivity.this,utube.class);
startActivity(facebook);
}
});
b6=(Button)findViewById(R.id.google);
b6.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent facebook=new Intent(MainActivity.this,google.class);
startActivity(facebook);
}
});
b7=(Button)findViewById(R.id.twitter);
b7.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent facebook=new Intent(MainActivity.this,twitter.class);
startActivity(facebook);
}
});
}
}
This is the Facebook class I have used here with webview to open the Facebook page:
public class facebook extends Activity{
WebView facebook;
#SuppressLint("SetJavaScriptEnabled")
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.facebook);
facebook=(WebView)findViewById(R.id.webfacebook);
facebook.getSettings().setJavaScriptEnabled(true);
facebook.loadUrl("https://facebook.com");
}
Here I have implemented onbackPressed() and called finished() The onbackpressed method isn't affecting this at all.
#SuppressLint("NewApi")
#Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
finish();
Intent i=new Intent(facebook.this,MainActivity.class);
startActivity(i);
}
}
1> first is main activity page where there are icon of social sites when
i click on facebook icon it will open facebook as 2nd facebookActivity page,3> when i clicked back it will open a blank page and4>. nd when i again press back button it will opened the main activity page...
Change your onBackPressed() method like this:
#Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
finish();
Intent i=new Intent(getApplicationContext(),MainActivity.class);
startActivity(i);
}

passing values by buttons and count the whole thing

I have 3 classes. In every class I have 2 buttons like yes and no.
I want to pass 1 for yes and 0 for no.Finally I want to count the total number,
I mean if someone presses ' yes ' every time then it should be 3.
How to do it?`
passing values by buttons and count the whole thing
//this is 1st class
package com.atlantis.learnactivities;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Main extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b1 = (Button) findViewById(R.id.b1);
b1.setOnClickListener (new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Main.this,Second.class));
}
});
Button b2 = (Button) findViewById(R.id.b2);
b2.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Main.this,Second.class));
}
});
}
#Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
//this is 2nd class
package com.atlantis.learnactivities;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Second extends Activity {
String gender =null;
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second);
Button b3 = (Button) findViewById(R.id.b3);
b3.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Second.this,Three.class));
}
});
Button b4 = (Button) findViewById(R.id.b4);
b4.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(Second.this,Four.class));
}
});
}
}
Use sharedPreference.
When click button add an integer value.
To add
SharedPreferences.Editor editor = getPreferences(MODE_PRIVATE).edit();
editor.putInt("btn_value", "value");
editor.commit();
To retrieve data from shared preference
SharedPreferences prefs = getPreferences(MODE_PRIVATE);
int value = prefs.getInt("btn_value", -1);
In your current Activity, create a new Intent:
Intent i = new Intent(Main.this, Second.class);
i.putExtra("new_variable_name","value");
startActivity(i);
Then in the Second Activity, retrieve those values:
Bundle extras = getIntent().getExtras();
if (extras != null) {
String value = extras.getString("new_variable_name");
}
You don't need to use SharedPreferences to pass data in the same application.
If you don't need to Store the values and just pass it from one class to the next, use putExtra with intent.
Eg. Inside your click listener:
intent.putExtra("value", 1);
//or intent.putExtra("value", "1") , depending on whether you want to use it as a String or int
And in the class you are passing the value to, retrieve it
this.getIntent().getExtras().getString("value");
//this.getIntent().getExtras().getInt("value");
check:
http://pkhandroid.wordpress.com/2012/10/02/post9-intent-message-passing-within-activities/
http://mobileorchard.com/android-app-development-using-intents-to-pass-data-and-return-results-between-activities/

Toast giving incorrect answer from Radio box references

I am pretty new to this and are not entirely sure why I am having this problem. From my code:
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.Toast;
public class MainActivity extends Activity {
RadioButton wavelength1;
RadioButton wavelength2;
double ray;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
wavelength1 = (RadioButton) findViewById(R.id.lowave);
wavelength2 = (RadioButton) findViewById(R.id.hiwave);
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// TODO Auto-generated method stub
If (wavelength1.isChecked());{
ray = 0.7125;
}
If (wavelength2.isChecked());{
ray = 0.4436;
}
Toast.makeText(MainActivity.this, String.valueOf(ray), Toast.LENGTH_LONG).show();
}
private void If(boolean checked) {
// TODO Auto-generated method stub
}
});
}
}
When I click on either radio boxes, the same output is given in the toast (as 0.4436) when they should be different. I am really at a loss to know what is going on. The app is aimed at API 10 and I am using Eclipse. (I am sure I am missing something).
Remove semicolor(;) at the end of if statement
If (wavelength1.isChecked()); < -- remove this
And also
use small (i) if it is method If();
remove this method
private void If(boolean checked) {
}

Categories

Resources