Where to write java code in Android app -


i started learning how create android app , i'm stuck methods in mainactivity.java. don't know write java code because app crashing.

package com.cidecode.loveometer;  public class mainactivity extends actionbaractivity {     @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);         if (savedinstancestate == null) {             getsupportfragmentmanager().begintransaction()                 .add(r.id.container, new placeholderfragment())                 .commit();         }     }      @override     public boolean oncreateoptionsmenu(menu menu) {         getmenuinflater().inflate(r.menu.main, menu);         return true;     }      @override     public boolean onoptionsitemselected(menuitem item) {         int id = item.getitemid();         if (id == r.id.action_settings) {             return true;         }         return super.onoptionsitemselected(item);     }      public static class placeholderfragment extends fragment {         public placeholderfragment() {         }          @override         public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {             view rootview = inflater.inflate(r.layout.fragment_main, container, false);             return rootview;         }     } } 

things want created when activity started should in oncreate method (buttons , onclicklisteners etc). if example have button have stated onclick name in xml file (rather put onclicklistener on it) can put function long not after last curly brace finishes activity. should try new boston tutorials on youtube, found explained lot , helped me understand needed put things.


Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -