java - opening new content view -


in main.class creating dynamic scrollview , starting using setcontentview(sv) displays spinner , button.

the user selects option spinner , clicks button. have set setonclicklistener button.

in onclick method trying start new contentview. calling new class file same type of layout main.class. not sure how go doing this. added finish() onclick method , closes original window not sure how open new one.

here main.class code:

    @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      this.messages = new messages(this);     this.datasource = new facilitiesdatasource(this);     this.datasource.open();      scrollview sv = new scrollview(this);     linearlayout ll = new linearlayout(this);     ll.setorientation(linearlayout.vertical);     sv.addview(ll);           spinner s = new spinner(this);     s.setid(spinner_facilities);     s.setlayoutparams(new spinner.layoutparams(-2,-1));     final list<spinnerobject> list = this.datasource.getfacilitieslist();     final arrayadapter<spinnerobject> adapter = new arrayadapter<spinnerobject>(this, android.r.layout.simple_spinner_dropdown_item, list);     adapter.setdropdownviewresource(android.r.layout.simple_spinner_dropdown_item);     s.setadapter(adapter);     ll.addview(s);      button b = new button(this);     b.settext("submit");     b.setlayoutparams(new layoutparams(-2,-1));     b.setonclicklistener(new onclicklistener(){          @override         public void onclick(view arg0) {             spinner spin = (spinner)findviewbyid(spinner_facilities);             log.v("option picked",  integer.tostring(( (spinnerobject) spin.getselecteditem () ).getid () ));             /*              * need here               * need here               * need here               */             //finish();         }      });     ll.addview(b);     setcontentview(sv); } 

here vehicles.class:

    @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     log.v("started oncreate", "vehicle");     scrollview sv = new scrollview(this);     setcontentview(sv); } 

i assume mean want start new activity (from main vehicles). in case can use following code:

intent intent = new intent(main.this, vehicle.class); startactivity(intent); 

make sure activity classes declared in android manifest file, inside <application> tag, this:

<activity android:name=".vehicles" /> 

Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -