using a ListPicker in JavaBridge

54 views
Skip to first unread message

bernhard

unread,
Feb 20, 2012, 1:00:39 AM2/20/12
to Android Programming at USF
Hi,

i'd like to use a ListPicker, which options should be filled
dynamically.

To fill the ListPicker I thougt I would just override the
BeforePicking and fill the listpicker with elements.
Unfortunately I'm stuck here.
The app crashes as soon as i call my function getCoordsFromLocation...

Any hints?

bernhard

public class myListPickerCheckbox extends ListPickerCheckbox {

public myListPickerCheckbox(ComponentContainer container) {
super(container);
}

@Override
public void BeforePicking() {
super.BeforePicking();
strArray = getCoordsFromLocation("789 38th ave");
YailList yailList = YailList.makeList(strArray);
this.Elements(yailList);
this.SelectionStlye(Component.SINGLE_CHOICE);
Log.d("no", "picker opened");
}
}

bernhard

unread,
Feb 20, 2012, 1:41:29 AM2/20/12
to Android Programming at USF
ah forgot to mention - if anybody implemented a sucessful
implementation of a listpicker using java bridge (doesn't have to be
related to the implementation I tried) pls let me know how you
accomplished that...
thx
bernhard

M. Hossein Amerkashi

unread,
Feb 20, 2012, 10:33:41 AM2/20/12
to android-progr...@googlegroups.com
The process that I do is basically as follows:

create a ListPicker (e.g. picker) and set its visibility to false
create a Button (e.g. btn1) and set its text and all
register Click event
when Click and component is btn1, then:
load your picker elements
picker.open

Hope this helps,
Hossein.

Bernhard Schelling

unread,
Feb 20, 2012, 11:08:10 AM2/20/12
to android-progr...@googlegroups.com
Ok thanks I'll try that.
Could you give a short explanation of why the BeforePicking event is
not the right way to populate
the Picker with data?
Bernhard

Bernhard Schelling

unread,
Feb 20, 2012, 11:47:23 AM2/20/12
to android-progr...@googlegroups.com
Unfortunately I think I can't use the suggested solution:

As far as i can see the makeList method from YailList is static -
therefore it requires
a static strArray. Since I have to generate the list elements on the
fly, I don't think
i will be able to use it.

YailList yailList = YailList.makeList(strArray);

If I try to do a new YailList and than YailList.setItems I can only
get to ListPickerCheckbox.Elements - which again wants
a static yailList.

I have to come up with a solution and I'm running out of time - so for
the time being, I'll go for a Dialog.
Comments welcome :)

Bernhard

David W Wolber

unread,
Feb 20, 2012, 12:25:41 PM2/20/12
to android-progr...@googlegroups.com
Hi Bernhard. I'll play with this now,

Dave

David W Wolber

unread,
Feb 20, 2012, 12:26:51 PM2/20/12
to android-progr...@googlegroups.com
When you call the get coordinates from address, make sure the thing returned back to you isn't null.

Dave

Bernhard Schelling

unread,
Feb 20, 2012, 12:49:31 PM2/20/12
to android-progr...@googlegroups.com
thanks, i think i checked for that.
but i tried so many different ways by now to get this simple
listpicker working that i can't say for sure.
the dialog works for me so at least i got a solution :)

bernhard

David W Wolber

unread,
Feb 20, 2012, 12:54:59 PM2/20/12
to android-progr...@googlegroups.com
Hi Bernhard. Yes, go forward without. I explored a bit but will need more time how to correctly configure the Java Bridge listpicker 


Dave

David W Wolber

unread,
Feb 20, 2012, 2:24:07 PM2/20/12
to android-progr...@googlegroups.com
Hi Hossein. I played around with the ListPicker and ran into some issues. Specifically, when the button is clicked and the system tries to open the list picker (activity), it says its unable to find explicit activity class (see below).

I explored the classes and it looks like Picker registers an activity dynamically... anyway, any help would be appreciated, and my src code is attached.

Dave




02-20 11:19:14.843: E/AndroidRuntime(1059): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.wolber.samples/com.google.devtools.simple.runtime.components.android.ListPickerActivity}; have you declared this activity in your AndroidManifest.xml?
02-20 11:19:14.843: E/AndroidRuntime(1059): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1404)
02-20 11:19:14.843: E/AndroidRuntime(1059): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1378)
02-20 11:19:14.843: E/AndroidRuntime(1059): at android.app.Activity.startActivityForResult(Activity.java:2749)
02-20 11:19:14.843: E/AndroidRuntime(1059): at com.google.devtools.simple.runtime.components.android.Picker.click(Picker.java:40)
02-20 11:19:14.843: E/AndroidRuntime(1059): at com.google.devtools.simple.runtime.components.android.ButtonBase.onClick(ButtonBase.java:430)
02-20 11:19:14.843: E/AndroidRuntime(1059): at android.view.View.performClick(View.java:2364)


On Mon, Feb 20, 2012 at 7:33 AM, M. Hossein Amerkashi <kkas...@gmail.com> wrote:
ListViewBridgeSampleActivity.java

M. Hossein Amerkashi

unread,
Feb 20, 2012, 2:34:58 PM2/20/12
to android-progr...@googlegroups.com
Hi David,

Yes, that is correct. That activity needs to be specified in androidmanifest; wiki: http://code.google.com/p/apptomarket/wiki/AndroidManifest

Also, if you use the ListPickerCheckbox, then its associated activity should also be specified in androidmanifest (wiki http://code.google.com/p/apptomarket/wiki/ListPickerCbRbActivity)

<activity android:name="com.google.devtools.simple.runtime.components.android.ListPickerCheckboxActivity" />

Hope this helps,
Hossein

David W Wolber

unread,
Feb 20, 2012, 2:48:11 PM2/20/12
to android-progr...@googlegroups.com
thanks Hossein, this worked and sorry, I see Bernhard already ran into this.

So the solution is, anytime you use a listpicker class, add:

<activity android:name="com.google.devtools.simple.runtime.components.android.ListPickerActivity" />

to your manifest, as the ListPicker has an associated ListPickerActivity that it tries to open.

Dave

M. Hossein Amerkashi

unread,
Feb 20, 2012, 8:46:28 PM2/20/12
to android-progr...@googlegroups.com
No problem David. The ListPicker is used to pass data to its activity and then receive results back from it.
Same concept implemented for ListPickerCheckbox

Since these pickers dynamically look-up their related activities, you don't get any compile time and instead get runtime issue.

The same goes for WebViewer and its related WebViewerActivity

-Hossein

Bernhard Schelling

unread,
Feb 20, 2012, 8:55:54 PM2/20/12
to android-progr...@googlegroups.com
Thanks Hossein for makeing this clear!

Still it would be nice to be able to dynamically update the data
displayed in the ListPickerCheckbox -
If there's a way for doing that, I'd really appreciate your feedback.

Bernhard

M. Hossein Amerkashi

unread,
Feb 20, 2012, 9:01:33 PM2/20/12
to android-progr...@googlegroups.com
That should work. I'll quickly put something together and post back.

-Hossein

M. Hossein Amerkashi

unread,
Feb 20, 2012, 9:52:29 PM2/20/12
to android-progr...@googlegroups.com
Please see attached. It has a textbox that allows you to enter data in CSV format. This way, you can experiment changing data and see how it looks on the 2 different picker types. I ran into some issue when using picker instead of button; didn't have time to look into it, but will do later.

-Hossein
ListPickerCbRbActivity.java

Bernhard Schelling

unread,
Feb 20, 2012, 10:07:49 PM2/20/12
to android-progr...@googlegroups.com
Thanks - this looks exactly how i needed it :)
Have to look into it...
Bernhard

M. Hossein Amerkashi

unread,
Feb 23, 2012, 1:54:26 PM2/23/12
to android-progr...@googlegroups.com
If you have a need for new feature, please add request HERE and I will try to implement.

Thanks

Bernhard Schelling

unread,
Feb 23, 2012, 2:35:29 PM2/23/12
to android-progr...@googlegroups.com
Hi Hossein,

I really appreciate that! I met with David Wolber the other day and
found out that I must
have done something wrong (still not exactly sure what but lost the
original code).
We used the onBeforePicking (?) event and it worked just like it should be.

Thanks again
Bernhard

Reply all
Reply to author
Forward
0 new messages