Friday, 15 June 2012

Android: how to concatenate spinner value with value in edittext -



Android: how to concatenate spinner value with value in edittext -

i have few issues spinner, implementing spinner below

spinner1 = (spinner) dialog.findviewbyid(r.id.quesspinner); arrayadapter<charsequence> arrayadapter = arrayadapter.createfromresource(activity, r.array.fbquestion,r.layout.textview); arrayadapter.setdropdownviewresource(r.layout.textview); spinner1.setadapter(arrayadapter); logo.setonclicklistener(new onclicklistener() { public void onclick(view v) { spinner1.setvisibility(view.invisible); spinner1.performclick(); } }); spinner1.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(adapterview<?> parent, view view, int pos, long id) { log.d(tag, "spinner value onitemselected--->"); string text =parent.getitematposition(pos).tostring(); log.d(tag, "spinner value onitemselected--->"+text); string messagetext = edittext.gettext().tostring(); edittext.settext(messagetext+text); int val = parent.getid(); log.d(tag, "spinner value onitemselected--->"+val); } @override public void onnothingselected(adapterview<?> arg0) { log.d(tag, "spinner value onnothingselected--->"); } });

my issues 1) how concatenate spinner value value in edittext ..if there no text in edittext should display spinner value if edittext has ,spinner value should concatenate edittext value.

string text =parent.getitematposition(pos).tostring(); string messagetext = edittext.gettext().tostring(); edittext.settext(messagetext+text);

doing above code not working properly

2) when click on spinner , if dont want select , click getting value of first item. how handle no value should select when user hits backbutton.

android android-spinner

No comments:

Post a Comment