public class Activity extends Activity implements VIEw.OnClickListener{ private Spinner spinner0,spinner1,spinner2,spinner3; private button submit,cancel; private String country[],state[],city[],area[]; Australia aus = new Australia(); Object object; /** Called when the activity is first created. */ @OverrIDe public voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); spinner0 = (Spinner)findVIEwByID(R.ID.spinnerCountry); spinner1 = (Spinner)findVIEwByID(R.ID.spinnerQ1); spinner2 = (Spinner)findVIEwByID(R.ID.spinnerQ2); spinner3 = (Spinner)findVIEwByID(R.ID.spinnerQ3); submit = (button)findVIEwByID(R.ID.btnsubmit); cancel = (button)findVIEwByID(R.ID.btnCancel); submit.setonClickListener(this); cancel.setonClickListener(this); country = new String[] {"Select Country","Australia","USA","UK","New Zealand","EU","Europe","China","Hong Kong","India","Malaysia","Canada","International","Asia","Africa"}; ArrayAdapter<String> adapter0 = new ArrayAdapter<String>(Activity.this,androID.R.layout.simple_spinner_item,country); adapter0.setDropDownVIEwResource(androID.R.layout.simple_dropdown_item_1line); spinner0.setAdapter(adapter0); Log.i("AAA","spinner0"); spinner0.setonItemSelectedListener(new OnItemSelectedListener() { @OverrIDe public voID onItemSelected(AdapterVIEw<?> arg0,VIEw vIEw1,int pos,long ID) { Log.i("AAA","OnItemSelected"); int loc; loc = pos; switch (loc) { case 1: state = aus.getState(); object = aus; Log.i("AAA","ArrayAdapter1"); ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(Activity.this,state); adapter1.setDropDownVIEwResource(androID.R.layout.simple_dropdown_item_1line); spinner1.setAdapter(adapter1); Log.i("AAA","spinner1"); break; default: Log.i("AAA","default 0"); break; } } @OverrIDe public voID onnothingSelected(AdapterVIEw<?> arg1) { Log.i("AAA","nothing S0"); } }); spinner1.setonItemSelectedListener(new OnItemSelectedListener() { @OverrIDe public voID onItemSelected(AdapterVIEw<?> arg0,long ID) { Log.i("AAA","OnItemSelected S1"); int loc = pos; switch(loc) { case 1: Log.i("AAA","Australia"); if(object.equals(aus)) { city = aus.getType(loc); } else { break; } ArrayAdapter<String> adapter = new ArrayAdapter<String>(Activity.this,city); adapter.setDropDownVIEwResource(androID.R.layout.simple_dropdown_item_1line); spinner2.setAdapter(adapter); Log.i("AAA","spinner2"); break; default: Log.i("AAA","default 1"); break; } } @OverrIDe public voID onnothingSelected(AdapterVIEw<?> arg0) { Log.i("AAA","nothing S1"); } }); spinner2.setonItemSelectedListener(new OnItemSelectedListener() { @OverrIDe public voID onItemSelected(AdapterVIEw<?> arg0,VIEw arg1,long ID) { int loc = pos; switch (loc) { case 1: if(object.equals(aus)) { area = aus.getTitle(loc); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(Activity.this,area); adapter.setDropDownVIEwResource(androID.R.layout.simple_dropdown_item_1line); spinner3.setAdapter(adapter); Log.i("","spinner3"); break; default: break; } } @OverrIDe public voID onnothingSelected(AdapterVIEw<?> arg0) { // Todo auto-generated method stub } }); }// on-create @OverrIDe public voID onClick(VIEw v) { switch (v.getID()) { case R.ID.btnsubmit: break; case R.ID.btnCancel: finish(); break; default: break; } } }
如果你觉得这很有用,那就放弃投票,让别人可以很容易地找到一个很好的答案.
对于每个国家,你必须为它创建一个课程,只需添加州,城市&区.这样一来,它就不会变成一个单一的网格.
玩的开心.
问候,
HAPS.
总结以上是内存溢出为你收集整理的android – 如何使用微调全部内容,希望文章能够帮你解决android – 如何使用微调所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)