I'm not a programmer, but I have a question and I can not find where to answer it.
I have a multichoice array, It turns out that when I get the "checkable" I can see them in a single String. I would like each item that is with its "check" to be saved in a different object, or if there is a way to separate the Strings from the only textView and then be sent to the database, it would be great.
The problem that I have is that everything I select is placed in the TextView in a linear way separated by a comma, and I would like that in addition to that, I can save them independently in the database. I am using AndroidStudio, and the database is Firebase Realtime Database
I hope someone can help me. Thanks in advance.
profTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
AlertDialog.Builder mBuilder = new AlertDialog.Builder(Perfil.this);
mBuilder.setTitle(R.string.profesi_n);
mBuilder.setMultiChoiceItems(listItems, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int position, boolean isChecked) {
if(isChecked){
mProfesionItems.add(position);
}else{
mProfesionItems.remove((Integer.valueOf(position)));
}
}
});
mBuilder.setCancelable(false);
mBuilder.setPositiveButton(R.string.ok_label, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int which) {
String item = "";
for (int i = 0; i < mProfesionItems.size(); i++) {
item = item + listItems[mProfesionItems.get(i)];
if (i != mProfesionItems.size() - 1) {
item = item + ", ";
}
}
profTextView.setText(item);
dataReference.child("perfiles").child(user_id).child("profesion").setValue(profTextView);
}
});
AlertDialog mDialog = mBuilder.create();
mDialog.show();
}
});