How to add a title bar in Android while sorting? -



How to add a title bar in Android while sorting? -

here code:

public class mainactivity extends activity { spinner spin; textview tex; string[] country = {"a", "afghanistan", "albania", "etc"};// z country names string[] code = {"+93", "+91", "etc"}; // z country code protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); spin = (spinner)findviewbyid(r.id.spinner1); tex = (textview)findviewbyid(r.id.tex); arrayadapter aa1 = new arrayadapter(this, android.r.layout.simple_spinner_item, country); aa1.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item); spin.setprompt("select country"); spin.setadapter(aa1); spin.setonitemselectedlistener(new onitemselectedlistener() { @override public void onitemselected(adapterview<?> arg0, view arg1, int arg2, long arg3) { tex.settext(code[arg2]); // tex.settext(country[arg2]); } @override public void onnothingselected(adapterview<?> arg0) { // todo auto-generated method stub } }); } }

i want display country's list in alphabetic order on spinner. , before should display a, b, c z. z must unselectable mode in spinner list. how can accomplish that?

you'll have create custom adapter extends arrayadapter.

it easy, like:

// view on adapter getview(layoutinflater, etc, etc){ convertview = super.getview(inflater, etc, etc); if(getitem(position).equals("a") || getitem(position).equals("b") || // etc, or create clever way go through arraylist letters ){ convertview. // set not clickable stuff } }

but reckon spinner still close list whenever user clicks. maybe must override spinner onitemclick coherent behaviour.

android sorting spinner

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -