dongqiuge5435 2015-09-01 10:20
浏览 30

从单个表的4种不同方法向mysql发送值

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 易康econgnition精度验证
    • ¥15 线程问题判断多次进入
    • ¥15 msix packaging tool打包问题
    • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致