1 Replies - 2654 Views - Last Post: 12 February 2014 - 10:43 AM

#1 James1992  Icon User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 132
  • Joined: 30-October 12

How to store value of rating bar and spinner.

Posted 12 February 2014 - 08:37 AM

I am currently trying to store the value of a rating bar and spinner so that I can pass it into my SQLite.

I've attached the code I am using.
Spinner edittext1=(Spinner )findViewById(R.id.spinner1);
RatingBar edittext2=(RatingBar )findViewById(R.id.ratingBar1);
EditText edittext3=(EditText )findViewById(R.id.txtComment);

	     db.execSQL("INSERT INTO  Feedback VALUES('"+food+"','"+rating+"', '"+comment+"');");

When I then check to see what has been entered, only the EditText (txtComment) has been entered correctly.
The Spinner and RatingBar enter something to do with the file (i.e. [email protected])

I'm not sure whether the problem exists when I'm trying to get the values and store them into edittext1 and edittext2 or when i try to get the .getContext of each.

Any suggestions?

This post has been edited by James1992: 12 February 2014 - 08:38 AM

Is This A Good Question/Topic? 0
  • +

Replies To: How to store value of rating bar and spinner.

#2 Apokio  Icon User is offline

  • D.I.C Addict

Reputation: 135
  • View blog
  • Posts: 511
  • Joined: 14-August 09

Re: How to store value of rating bar and spinner.

Posted 12 February 2014 - 10:43 AM

For the Spinner and the Rating bar you have to get the data from the listeners for each view. In the onItemSelected Listener you would use the parent.getItematPosition(pos) to retrieve what the user selected. Read the Android docsHere. Another note named your variables for the Spinner and Rating bar edittext* makes it very confusing.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1