I am writing a block of code where I am programmatically creating a SeekBar
to capture a percentage. The percentage is then displayed in a TextView
. I have written the code to display both on screen:
public static void pebbleTypeHandler(LinearLayout layout, final TaskSwitcherTask task, PData value)
{
// Create an android seek bar to allow thumb drag
// Have a text view to display the value
Log.v(PebbleTypeHandlerPercentage.class.toString(), "-----> Percentage");
SeekBar seekbar = new SeekBar(task.getParent());
TextView textView = new TextView(task.getParent());
textView.setTextColor(ColorStateList.valueOf(0xFFFFFFFF));
textView.setText(((PPercentage) value).getValue() + "%");
layout.addView(textView);
layout.addView(seekbar);
int id = UtilityMethods.getNextId();
value.getMeta().getDataPebble().setId(id);
textView.setId(id);
id = UtilityMethods.getNextId();
seekbar.setId(id);
Log.v(PebbleTypeHandlerLevel.class.toString(), "-----> TextView ID: " + textView.getId());
Log.v(PebbleTypeHandlerLevel.class.toString(), "-----> SeekBar ID: " + seekbar.getId());
}
How can I handle the SeekBar
change. I want the TextView
value to change depending on the thumb position. The maximum percentage is 100% and the minimum is 0%.
I would also like to set an onClickListener
on the TextView
and update the position of the SeekBar
based on the entered value to allow for more accurate values to be entered. The value in my data carrier, called Pebble, is a float as I would like to allow Float
numbers.
Any help would be appreciated.
Regards,
Owen