Initial spinner selection

80 views
Skip to first unread message

Simon Craigie

unread,
Sep 23, 2014, 10:41:58 AM9/23/14
to robob...@googlegroups.com
Hello,

I want to display a hint in my spinner when no selection has been made.  

I am trying to do this by creating a custom ArrayList to use as the spinner source as follows:

public class SpinnerList extends ArrayList<String> {

        @Override
        public int size() {
            int listSize = super.size();

            return listSize <= 0 ? 0 : listSize - 1;
        }

}


list = new SpinnerList();
list.add("foo");
list.add("bar");
list.add.....
list.add.....
list.add.....
list.add.....
list.add(""); // <- when selected, this will display the hint from my spinner textview.

This implementation is working fine with robobinding as index 0 to (n-1) are displayed in the spinner list, however I cannot set the index to the last element nor any other element in my list except position 0 without throwing an error.  

can anybody help with a solution to change the initial item selection?

Thanks!

wei cheng

unread,
Sep 23, 2014, 10:53:00 AM9/23/14
to robob...@googlegroups.com

Hi Simon,

I don't fully understand your problem. Could you send a minimal sample project to weich...@gmail.com or through some other way like github. I will have a look tomorrow and give you a feedback.

Cheers,
Cheng Wei

--
You received this message because you are subscribed to the Google Groups "RoboBinding" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robobinding...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

cheng

unread,
Sep 24, 2014, 2:51:04 AM9/24/14
to robob...@googlegroups.com
Hi Simon,

I re-read your issue. Are you using PresentationModels with aspectj? if so, the bug you mentioned might be to do with the bug #172, which was introduced in the version 0.8.6 and fixed in the version 0.8.7, which has just released.

Cheers,
Cheng Wei

在 2014年9月23日星期二UTC+8下午10时53分00秒,cheng写道:
To unsubscribe from this group and stop receiving emails from it, send an email to robobinding+unsubscribe@googlegroups.com.

cheng

unread,
Sep 25, 2014, 4:56:07 AM9/25/14
to robob...@googlegroups.com
Hi Simon,

Thanks for the sample project. I tried and found this thread. I think this is a bug that Google has introduced, but i will have a look to see if RoboBinding can have a workaround this. Thanks for a good spot.

Best Regards,
Cheng Wei

在 2014年9月24日星期三UTC+8下午2时51分04秒,cheng写道:

cheng

unread,
Sep 25, 2014, 5:17:02 AM9/25/14
to robob...@googlegroups.com
Ok, with further reading. I think it is a bug in RoboBinding.

Best Regards,
Cheng Wei

在 2014年9月25日星期四UTC+8下午4时56分07秒,cheng写道:

cheng

unread,
Sep 26, 2014, 3:56:39 AM9/26/14
to robob...@googlegroups.com
Hi Simon,

I have fixed the problem. You can have a try with the latest robobinding 0.8.8-SNAPSHOT. For the ItemPresentationModel, i removed AbstractItemPresentationModel in 0.8.7 to prevent confusion. Please have a look the following code sample:

public class ListItemPresentationModel extends AbstractPresentationModel implements ItemPresentationModel<String> {

    private String item;

    public ListItemPresentationModel(){}

    public String getValue(){
        return item;
    }

    @Override
    public void updateData(int index, String item) {
    this.item = item;
    }
}

Best regards,
Cheng Wei

在 2014年9月23日星期二UTC+8下午10时41分58秒,Simon Craigie写道:

Johnny TwoShoes

unread,
Jan 6, 2016, 3:53:15 AM1/6/16
to RoboBinding
Hi,

Did you get the code the spinner to select the index > 0 ?? Can you show me the code please?

kind regards
Reply all
Reply to author
Forward
0 new messages