I need to use the Switch widget as a link or a button (this is for design reasons beyond me). If you click on the Switch then a WebView opens. There must be no animation or appearance change in the Switch.
This is my naive code:
public class MainActivity extends Activity {
private WebView wv;
private Switch s;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
s = new Switch(this);
s.setClickable(true);
linearLayout.addView(s);
wv = new WebView(this);
wv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
wv.setWebViewClient(new WebViewClient());
linearLayout.addView(wv);
super.setContentView(linearLayout);
}
@Override
protected void onResume() {
super.onResume();
s.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
wv.loadUrl("https://www.google.com");
}
});
}
}
Do you know if I can disable the animation and appearance change in the Switch widget?
I found an okayish solution: