callback for other android widgets

53 views
Skip to first unread message

Peter Rainaud

unread,
Mar 24, 2012, 8:17:08 PM3/24/12
to Hecl
Hi

I want to add a seekbar to a script
and some callback to get the value of the position of the pointer

I tried the following:

# Callback --
#
# Generic callback proc to hand off to various widgets.

proc Callback {args} {
set args [lrange $args 1 -1]
gui {alert "Callback called with arguments: $args"}
}

java android.widget.SeekBar seekbar
set sb [seekbar -new $context \
-layoutparams $layoutparams]

set callback [callback -new [list [list Callback]]]
$sb OnSeekBarChangeListener $callback
$layout addview $sb


Now the interpreter complains about:
method onseekbarchangelistener not found for classclass
android.widget.SeekBar.

The method does exist. But somehow i'm not doing it
the right way.

Can someone give me a hint.

Kind regards,

Peter

zdia

unread,
Mar 25, 2012, 2:43:34 AM3/25/12
to he...@googlegroups.com


Am 25.03.2012 01:17, schrieb Peter Rainaud:

> Now the interpreter complains about: method onseekbarchangelistener
> not found for classclass android.widget.SeekBar.

This message you will see quite often :-)

In general it means that the method did not get the right parameters and
you have to do some experiments.


The Android manual says:

Public Methods
public void setOnSeekBarChangeListener (SeekBar.OnSeekBarChangeListener l)


So try to add the word "set" to the method:


set callback [callback -new [list [list Callback]]]
$sb setOnSeekBarChangeListener $callback
$layout addview $sb

peter rainaud

unread,
Mar 27, 2012, 6:20:41 AM3/27/12
to Hecl
Hi Zdia,

I have to add something more in HeclCallback.java it seems:

So I'v added:

in the header:
import android.widget.SeekBar;

public class HeclCallback implements
android.view.View.OnClickListener,
android.widget.AdapterView.OnItemClickListener,
android.widget.AdapterView.OnItemSelectedListener,
android.widget.DatePicker.OnDateSetListener,
android.widget.TimePicker.OnTimeSetListener,
android.widget.TimePicker.OnTimeChangedListener,

android.widget.SeekBar.OnOnSeekBarChangeListener,
android.widget.CompoundButton.OnCheckedChangeListener {

add the 3 methods which are necessary for the seekbar widget

public void onProgressChanged(SeekBar seekbar, int progress, boolean
fromTouch) {
try {
Vector vec = ListThing.get(script.deepcopy());
vec.add(ObjectThing.create(seekbar));
vec.add(IntThing.create(progress));
vec.add(IntThing.create(fromTouch));
interp.eval(ListThing.create(vec));
} catch (HeclException he) {
Hecl.logStacktrace(he);
Log.v("hecl onProgressChanged callback", he.toString());
}
}

}

public void onStartTrackingTouch(SeekBar seekbar) {
try {
Vector vec = ListThing.get(script.deepcopy());
vec.add(ObjectThing.create(seekbar));
interp.eval(ListThing.create(vec));
} catch (HeclException he) {
Hecl.logStacktrace(he);
Log.v("hecl onProgressChanged callback", he.toString());
}
}

public void onStopTrackingTouch(SeekBar seekbar) {
try {
Vector vec = ListThing.get(script.deepcopy());
vec.add(ObjectThing.create(seekbar));
interp.eval(ListThing.create(vec));
} catch (HeclException he) {
Hecl.logStacktrace(he);
Log.v("hecl onProgressChanged callback", he.toString());
}
}

Recompilation gave no error. great!

I reinstalled hecl_debug.apk

Now the script runs but the callback does nothing :-)

I think it's a minor issue.

How can I check the hecl log on a real device?

Kind regards,

Peter




On 25 mrt, 08:43, zdia <z....@gmx.de> wrote:
> Am 25.03.2012 01:17, schrieb Peter Rainaud:
>
> > Now the interpreter complains about: method onseekbarchangelistener
> > not found for classclass android.widget.SeekBar.
>
> This message you will see quite often :-)
>
> In general it means that the method did not get the right parameters and
> you have to do some experiments.
>
> The Android manual says:
>
> *Public Methods
> public void setOnSeekBarChangeListener (SeekBar.OnSeekBarChangeListener l)*

peter rainaud

unread,
Mar 28, 2012, 4:48:31 AM3/28/12
to Hecl
Thanks to the feedback of the logging I found the problem and seekbar
works now.

So:
Enable usb-debug on the device

connect device via usb

navigate to ../platform-tools

./adb logcat
> > $layout addview $sb- Tekst uit oorspronkelijk bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

zdia

unread,
Mar 30, 2012, 1:52:32 PM3/30/12
to he...@googlegroups.com


Am Mittwoch, 28. März 2012 10:48:31 UTC+2 schrieb peter rainaud:

Thanks to the feedback of the logging I found the problem and seekbar
works now.

Congratulations!

Could you post how you discovered the error and how you fixed it?

Did you need to add explicitely icons for the seekbar widget?

It would be fine if you would post the Hecl code for final implementing of the seekbar, too.

By the way, perhaps you will be confused during a debugging session if you get identical logcat messages for all of your new seekbar methods:
Reply all
Reply to author
Forward
0 new messages