Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/179.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 将SeekBar值传递到mysql数据库_Android_Mysql - Fatal编程技术网

Android 将SeekBar值传递到mysql数据库

Android 将SeekBar值传递到mysql数据库,android,mysql,Android,Mysql,我正在编写一个简单的程序,用户将seekbar推到某个级别,然后将该级别保存到mysql数据库中。如何从方法中获取seekbar值并将其发布?因为我对android编程还不熟悉,所以我被卡住了。这里的任何帮助都是非常必要的 我知道目前的问题是seekbar是int值,我正在尝试使用string。如何将下面的公共void poslji更改为使用int而不是string public class MainActivity extends AppCompatActivity { priv

我正在编写一个简单的程序,用户将seekbar推到某个级别,然后将该级别保存到mysql数据库中。如何从方法中获取seekbar值并将其发布?因为我对android编程还不熟悉,所以我被卡住了。这里的任何帮助都是非常必要的

我知道目前的问题是seekbar是int值,我正在尝试使用string。如何将下面的公共void poslji更改为使用int而不是string

public class MainActivity extends AppCompatActivity {



    private TextView test;
    private TextView textView;
    private ImageView imageView;
    private SeekBar seekBar;


   @Override
     protected void onCreate(Bundle savedInstanceState) {
       super.onCreate( savedInstanceState );
       setContentView( R.layout.activity_main );

       seekBar = (SeekBar) findViewById( seek_bar_id );


       initializeVariables();

       textView.setText( "Jakost bolečine: " + seekBar.getProgress() + "/" + seekBar.getMax() );

       seekBar.setOnSeekBarChangeListener( new OnSeekBarChangeListener() {
           int progress = 0;

           @Override
           public void onProgressChanged(SeekBar seekBar, int progresValue, boolean fromUser) {
               progress = progresValue;
           }

           @Override
           public void onStartTrackingTouch(SeekBar seekBar) {
           }

           @Override
           public void onStopTrackingTouch(final SeekBar seekBar) {

               textView.setText( "Jakost bolečine: " + progress + "/" + seekBar.getMax() );
               if (progress == 0) {

                   imageView.setImageResource( R.drawable.no_pain );
               }
               if (progress <= 2 && progress >= 1) {
                   imageView.setImageResource( R.drawable.little_pain );
                   Toast.makeText( getApplicationContext(), "Blaga bolečina!", Toast.LENGTH_SHORT ).show();
               }

               if (progress <= 4 && progress >= 3) {
                   imageView.setImageResource( R.drawable.moderata_pain );
                   Toast.makeText( getApplicationContext(), "Zmerna bolečina!", Toast.LENGTH_SHORT ).show();
               }

               if (progress <= 6 && progress >= 5) {
                   imageView.setImageResource( R.drawable.severe_pain );
                   Toast.makeText( getApplicationContext(), "Srednja bolečina!", Toast.LENGTH_SHORT ).show();
               }

               if (progress <= 8 && progress >= 7) {
                   imageView.setImageResource( R.drawable.very_severe_pain );
                   Toast.makeText( getApplicationContext(), "Dokaj močna bolečina!", Toast.LENGTH_SHORT ).show();
               }

               if (progress <= 10 && progress >= 9) {
                   imageView.setImageResource( R.drawable.worst_pain );
                   Toast.makeText( getApplicationContext(), "Zelo močna bolečina!", Toast.LENGTH_SHORT ).show();
               }

               test.setText( "" + progress );


           }

       } );


   }
    private void initializeVariables() {
        seekBar = (SeekBar) findViewById(R.id.seek_bar_id);
        textView = (TextView) findViewById(R.id.jakost_bolecin_id);
        test = (TextView) findViewById(R.id.test);
        imageView=(ImageView)findViewById( R.id.slika_bolecine );

    }

要将字符串转换为整数,请使用:

int integerHere = Integer.parseInt(stringToConvert);
int integerHere = Integer.parseInt(stringToConvert);