The App contains 4 textview which shows alertdialog with multichoice options while clicking. Where i am able to select the value and able to retrieve the selected values which is present in Array list. Each textview has 4 different void functions. The values from 4 different functions present in list are need to pass it to single mysql table. How can i collect the values from 4 different functions and pass it to the mysql table? I am aware of the passing values to mysql using php but how i collect the values and send it to mysql. Please help.
private void ilist() {
final CharSequence[] ratings = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
final ArrayList selectedratings = new ArrayList();
final boolean[] ratingschecked = {false, false, false, false, false, false, false, false, false, false};
SharedPreferences sharedPreferences = getSharedPreferences("checkedrate_i", Context.MODE_PRIVATE);
final SharedPreferences.Editor editor = sharedPreferences.edit();
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
int size = sharedPreferences.getInt("size", 0);
for(int j=0;j<size;j++)
{
selectedratings.add(sharedPreferences.getString("selectedratings" + j, null));
//Log.e("Kumar",""+selectedratings);
} for(int j=0;j<=ratingschecked.length;j++){
if(selectedratings.contains((String.valueOf(j)))) {
ratingschecked[j-1] = true;
}
}
builder.setTitle("Select Ratings");
builder.setMultiChoiceItems(ratings, ratingschecked, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked) {
if (isChecked) {
if(!selectedratings.contains((String)String.valueOf(ratings[which]))){
selectedratings.add(String.valueOf(ratings[which]));
ratingschecked[which]=true;
}
} else if ((selectedratings.contains((String)String.valueOf(ratings[which])))) {
selectedratings.remove(String.valueOf(ratings[which]));
// Log.e("Kumar", String.valueOf(ratings[which]));
ratingschecked[which]=false;
}
}
}).setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// editor.putString("checked", String.valueOf(selectedratings));
for (int i = 0; i < selectedratings.size(); i++) {
editor.putString("selectedratings" + i, String.valueOf(selectedratings.get(i)));
}
editor.putInt("size", selectedratings.size());
editor.apply();
//Log.e("Shiva", String.valueOf(selectedratings));
}
}).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
AlertDialog dialog = builder.create();
builder.show();
}
Like this i have 4 functions which each selected values are column values for a table. How can i collect selected values and send it to mysql using post.