Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can use </p> <p>SharedPreferences </p> <p><a href="http://developer.android.com/reference/android/content/SharedPreferences.html" rel="nofollow noreferrer">http://developer.android.com/reference/android/content/SharedPreferences.html</a></p> <p>Use This :-- </p> <pre><code> public class MultipleControllsActivity extends Activity { /** Called when the activity is first created. */ LinearLayout l1,l2,l3; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SharedPreferences pref_settings; pref_settings = getSharedPreferences("DATA", Context.MODE_PRIVATE); l1 = ((LinearLayout)findViewById(R.id.linearLayout1)); l2 = ((LinearLayout)findViewById(R.id.linearLayout2)); l3 = ((LinearLayout)findViewById(R.id.linearLayout3)); l1.setVisibility(pref_settings.getInt("l1", 0)); l2.setVisibility(pref_settings.getInt("l2", 0)); l2.setVisibility(pref_settings.getInt("l3", 0)); ((CheckBox)findViewById(R.id.checkBox1)).setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if(!isChecked){ l1.setVisibility(View.GONE); } } }); ((CheckBox)findViewById(R.id.checkBox2)).setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { l2.setVisibility(View.GONE); } }); ((CheckBox)findViewById(R.id.checkBox3)).setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { l3.setVisibility(View.GONE); } }); ((Button)findViewById(R.id.saveTemp)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { SharedPreferences pref_settings; pref_settings = getSharedPreferences("DATA", Context.MODE_PRIVATE); SharedPreferences.Editor editor = pref_settings.edit(); editor.putInt("l1", l1.getVisibility()); editor.putInt("l2", l2.getVisibility()); editor.putInt("l3", l3.getVisibility()); editor.commit(); } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload