Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Internet Explorer alert
This browser is not recommended for use with smartdevicelink.com, and may not function properly. Upgrade to a different browser to guarantee support of all features.
close alert
To Top Created with Sketch. To Top
To Bottom Created with Sketch. To Bottom
Android Guides
Slider

Slider

A Slider creates a full screen or pop-up overlay (depending on platform) that a user can control. There are two main Slider layouts, one with a static footer and one with a dynamic footer.

Note

The slider will persist on the screen until the timeout has elapsed or the user dismisses the slider by selecting a position or canceling.

A slider popup with a static footer displays a single, optional, footer message below the slider UI.

Slider UI

Slider with Static Footer 1

Creating the Slider

//Create a slider
Slider slider = new Slider(5, 1, "This is a Header");

List<String> footer = Collections.singletonList("Static Footer");
slider.setSliderFooter(footer);
slider.setOnRPCResponseListener(new OnRPCResponseListener() {
    @Override
    public void onResponse(int correlationId, RPCResponse response) {
        SliderResponse sliderResponse = (SliderResponse) response;
        Log.i(TAG, "Slider Position Set: "+ sliderResponse.getSliderPosition());
    }

    @Override
    public void onError(int correlationId, Result resultCode, String info){
        Log.e(TAG, "onError: "+ resultCode+ " | Info: "+ info );
    }
});

//Send Request
sdlManager.sendRPC(slider);

This type of slider will have a different footer message displayed for each position of the slider. The footer is an optional paramater. The footer message displayed will be based off of the slider's current position. The footer array should be the same length as numTicks because each footer must correspond to a tick value. Or, you can pass null to have no footer at all.

Slider UI

Dynamic Slider in Position 1

Slider with Dynamic Footer 1

Dynamic Slider in Position 2

Slider with Dynamic Footer 2

Creating the Slider

//Create a slider
Slider slider = new Slider(3, 1, "This is a Header");

// Each footer corresponds with the slider's position
List<String> footer = Arrays.asList("Footer 1","Footer 2","Footer 3");
slider.setSliderFooter(footer);
slider.setOnRPCResponseListener(new OnRPCResponseListener() {
    @Override
    public void onResponse(int correlationId, RPCResponse response) {
        SliderResponse sliderResponse = (SliderResponse) response;
        Log.i(TAG, "Slider Position Set: "+ sliderResponse.getSliderPosition());
    }

    @Override
    public void onError(int correlationId, Result resultCode, String info){
        Log.e(TAG, "onError: "+ resultCode+ " | Info: "+ info );
    }
});

//Send Request
sdlManager.sendRPC(slider);
View on GitHub.com
Previous Section Next Section