Im trying to translate RatingBar numOfStar() method into a string instead of an int. In tried to do numOfStar().ToString and it isnt possible.
How can i go about doing this. Because i want to save it as a string in SQLite database.
public RatingBar ratingbar;
ratingbar = (RatingBar)findViewById(R.id.ratingBar1);
private void saveState(){
book_name = title.getText().toString();
author = book_author.getText().toString();
isbn = isbn_number.getText().toString();
if(mRowId == null){
long id = mDbHelper.addBook(book_name, author, isbn, ratings);
if(id > 0 ){
开发者_如何学Python mRowId = id;
}
}else{
mDbHelper.updateBooks(mRowId, book_name, author, ratings, isbn);
}
String.valueOf(ratingbar.getRating())
ratingbar.setRating(Float.valueOf("some string"))
I may need to see some more code so that I know what RatingBar numOfStar is defined as, although the toString method in Java starts with a lower case 't' which is important as Java is case-sensitive.
String stringResult = numOfStar();
Use String.valueOf(value)
to convert a primitive type to a String.
精彩评论