title: How can I make a switch buttons change the background of an Android Studio TextView?
body: <p>I would like to know how I can change the background-color of a TextView, through a switch button. It is necessary to clarify that my switch buttons are in MainActivy and my TextView are in other Activities, to which I access like this:</p>
  <pre><code>tvBoton = (TextView) findViewViewById(R.id.Schedule);
          tvBoton.setOnClickListener(new View.OnClickListener() {
              @Override
                  public void onClick(View v) {
                      Intent i = new Intent(MainActivity.this, central.class);
                      startActivity(i);
                   }
              });
  </code></pre>
  <p>I don't know if it influences anything, but my switch buttons have SharePreferences:</p>
  <pre><code>pol = (Switch) findViewById(R.id.switch18);
          sharpol = getSharedPreferences(&quot;pol&quot;, MODE_PRIVATE);
          final SharedPreferences.Editor editorpol = sharpol.edit();
          pol.setChecked(sharpol.getBoolean(ex, false));
          pol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
              @Override
              public void onCheckedChanged(CompoundButton buttonView, boolean ispolChecked) {
                  if (ispolChecked) {
                      editorpol.putBoolean(ex, true);
                      politica=(TextView) findViewViewById(R.id.polit);
                      politica.setText(&quot;Not working&quot;);
                  } else {
                      editorpol.putBoolean(ex, false);
                  }
                  editorpol.commit();
              }
          });
  </code></pre>
  <p>As it is in the previous code, I tried inside the ispolChecked, in the true option, to reference the TetView, and then put setText, but this TextView, being inside another layout does not work. I also put setContentView(R.layout.main_activity) several times, but changing it to the respective layouts, but it didn't work either.</p>
  <p>Honestly, I don't know what to do anymore. Thanks for your answers.</p>