I am following a tutorial on the internet and I have a small question that is the following. In the tutorial, I put items from a String array in a listview and I can select multiple options in simple_list_item_checked.
I'm able to show which ones are selected and those that are not selected, what I needed is to play all the selected ones to another screen, the problem is how to play as String [], because in the example it's just as a String
What I need then is to throw all states for screen2 as the type String []
Does anyone help me? please?
listaEstados = new String[]{"São Paulo", "Rio de Janeiro", "Minas Gerais", "Rio Grande do Sul", "Santa Catarina", "Paraná"};
public void onClickMarcados(View view){
String listaEstadosSelec = "";
//Cria um array com os itens selecionados no listview
SparseBooleanArray selecionados = lv.getCheckedItemPositions();
for (int i=0; i<selecionados.size(); i++){
//Pega os itens marcados
listaEstadosSelec = listaEstadosSelec + listaEstados[selecionados.keyAt(i)]+", ";
}
Intent intent = new Intent(MainActivity.this, Tela2_Activity.class);
intent.putExtra("itens", listaEstadosSelec);
startActivity(intent);
//Toast.makeText(getBaseContext(), "Estados marcados: "+listaEstadosSelec, Toast.LENGTH_LONG).show();
}