This question is old, but it may help someone in the future.
Step 1
create a boolean variable in onCreate to make the if|else|while method easier (to be used in step 3)
boolean changedData = true;
Step 2
I want to display text in text mode when d list view is first loaded
Just leave your code as it is, assuming it looks like
ArrayAdapter<String> adapter = new ArrayAdapter<String>(yourActivity.this, android.R.layout.simple_list_item_1, yourData); listView.setAdapter(adapter);
Step 3
when I click the button, I want to fill out the list view with different data and which should also show a checkbox
just create a new button this way
populateBtn.setOnClickListener(new View.OnClickListener(){ @Override public void onClick(View v) { if (changedData == true) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(yourActivity.this, android.R.layout.simple_list_item_multiple_choice, differentData); listView.setAdapter(adapter); changedData = false; }else if (changedData == false) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(yourActivity.this, android.R.layout.simple_list_item_1, yourData); listView.setAdapter(adapter); changedData = true; } }); }
Thus, the first time you click the button, you get a ListView with CheckBox with the new data
And after clicking the button again, it will return to ListView without CheckBox with old data
If you want to make CheckBox available just read the answer from this link.
A simple list item element that does not select items