In the main view class / activity I have several checkboxes. Now in another class and with another view active, I would like to check the state of the checkboxes in the ‘main’ window of my Android app. How can I do that?
Here is what I tried:
protected String doInBackground(String... args) {
// Building Parameters
List<NameValuePair> params = new ArrayList<NameValuePair>();
setContentView(R.layout.main);
View v = findViewById(R.id.cbHasWifi);
CheckBox check = v.findViewById(R.id.cbHasWifi);
v.setContentView(v);
The whole code block gets me nowhere as it seems. I’m also worrying that another View context is active and may create followup problems if it is not ‘restored’ after my setContentView(), is that justified?
You cannot do anything to the UI in any thread other than the main UI thread, so trying to set a content view from
doInBackgroundis not going to work.Additionally, you haven’t made clear if you are running another activity or not. If you are running a new activity, there is no guarantee your data is still there from the first one.