Rating bar controls are the extension of seek bar controls, and allow a user to set the rating in stars. You can work with them in the same way as with seek bar controls, but also use the unique native methods and properties of the rating bar.
Determining if Rating Bar is Indicator
To check whether a rating bar is an indicator (cannot be changed by the user), use the isIndicator native method. If the control is an indicator, this method returns True; otherwise - False. The following example checks whether the rating bar is an indicator and posts the result to the log:
JavaScript, JScript
function Test()
					{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");
  
  // Obtain the RatingBar object
  var p = Mobile.Device().Process("com.example.myapp");
  var RatingBar = p.RootLayout("").Layout("layoutTop").Layout("layout1").RatingBar("ratingbar1");
  
  // Check if the rating bar is active
  if (RatingBar.isIndicator()) 
    // Post the result to the log 
    Log.Message("The rating bar is indicator only");
  else
    Log.Message("The rating bar can be touched");
					}
Python
def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  # Obtain the RatingBar object
  p = Mobile.Device().Process("com.example.myapp")
  RatingBar = p.RootLayout("").Layout("layoutTop").Layout("layout1").RatingBar("ratingbar1")
  
  # Check if the rating bar is active
  if RatingBar.isIndicator():
    # Post the result to the log 
    Log.Message("The rating bar is indicator only")
  else:
    Log.Message("The rating bar can be touched")VBScript
Sub Test()
  Dim p, RatingBar
  ' Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  ' Obtain the RatingBar object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set RatingBar = p.RootLayout("").Layout("layoutTop").Layout("layout1").RatingBar("ratingbar1")
  
  ' Check if the rating bar is active
  If RatingBar.isIndicator() then
    ' Post the result to the log 
    Log.Message("The rating bar is indicator only")
  else
    Log.Message("The rating bar can be touched")
  End If
End Sub
DelphiScript
procedure Test();
var 
  p, RatingBar : OleVariant; 
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');
  
  // Obtain the RatingBar object
  p := Mobile.Device.Process('com.example.myapp');
  RatingBar := p.RootLayout('').Layout('layoutTop').Layout('layout1').RatingBar('ratingbar1');
  
  // Check if the rating bar is active
  if RatingBar.isIndicator() then
    // Post the result to the log 
    Log.Message('The rating bar is indicator only')
  else
    Log.Message('The rating bar can be touched')
end;
C++Script, C#Script
function Test()
					{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");
  
  // Obtain the RatingBar object
  var p = Mobile["Device"]["Process"]("com.example.myapp");
  var RatingBar = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout1")["RatingBar"]("ratingbar1");
  
  // Check if the rating bar is active
  if (RatingBar["isIndicator"]()) 
    // Post the result to the log 
    Log["Message"]("The rating bar is indicator only");
  else
    Log["Message"]("The rating bar can be touched");
					}
Determining Number of Stars
To get the number of stars in the control,  use the mNumStars native field. This field returns the number of stars displayed by the control. The following example determines the total number of stars in the rating bar control and posts it to the log.
JavaScript, JScript
function Test()
						{
  // Select the Android device
  Mobile.SetCurrent("MyDevice");
  
  // Obtain the RatingBar object
  var p = Mobile.Device().Process("com.example.myapp");
  var RatingBar = p.RootLayout("").Layout("layoutTop").Layout("layout1").RatingBar("ratingbar1");
  
  // Get the number of stars
  var Stars = RatingBar.mNumStars;
  
  // Post the number to the log
  Log.Message(Stars);
						}
Python
def Test():
  # Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  # Obtain the RatingBar object
  p = Mobile.Device().Process("com.example.myapp")
  RatingBar = p.RootLayout("").Layout("layoutTop").Layout("layout1").RatingBar("ratingbar1")
  
  # Get the number of stars
  Stars = RatingBar.mNumStars
  
  # Post the number to the log
  Log.Message(Stars)VBScript
Sub Test()
  Dim p, RatingBar, Stars
  ' Select the Android device
  Mobile.SetCurrent("MyDevice")
  
  ' Obtain the RatingBar object
  Set p = Mobile.Device.Process("com.example.myapp")
  Set RatingBar = p.RootLayout("").Layout("layoutTop").Layout("layout1").RatingBar("ratingbar1")
  
  ' Get the number of stars
  Stars = RatingBar.mNumStars
  
  ' Post the number to the log
  Log.Message(Stars)
End Sub
DelphiScript
procedure Test();
var 
  p, SeekBar, Stars : OleVariant; 
begin
  // Select the Android device
  Mobile.SetCurrent('MyDevice');
  
  // Obtain the RatingBar object
  p := Mobile.Device.Process('com.example.myapp');
  RatingBar := p.RootLayout('').Layout('layoutTop').Layout('layout1').RatingBar('ratingbar1');
  
  // Get the number of stars
  Stars := RatingBar.mNumStars;
  
  // Post the number to the log
  Log.Message(Stars);
end;
C++Script, C#Script
function Test()
						{
  // Select the Android device
  Mobile["SetCurrent"]("MyDevice");
  
  // Obtain the RatingBar object
  var p = Mobile["Device"]["Process"]("com.example.myapp");
  var RatingBar = p["RootLayout"]("")["Layout"]("layoutTop")["Layout"]("layout1")["RatingBar"]("ratingbar1");
  
  // Get the number of stars
  var Stars = RatingBar["mNumStars"];
  
  // Post the number to the log
  Log["Message"](Stars);
						}
Using From Keyword Tests
This topic explains how to workng withrating bar the control in scripts. You can use the described fields in keyword tests too. To do this, use the On-Screen Action or the Call Object Method operations.
See Also
Working With Android Seek Bar Controls
Determining the Seek Bar Position
Changing Seek Bar Position
