Showing posts with label Activity. Show all posts
Showing posts with label Activity. Show all posts
Wednesday, August 17, 2011
View megjelenitese ures ListView eseten [Android]
Ha az Activity a ListActivity-bol szarmazik akkor kell lennie a layout-jan egy "@android:id/list" id-ju ListView-nak ami megjeleniti a listat, de lehet rajta meg egy "@android:id/empty" id-ju View is ami automatikusan megjlenik, ha a listank ures.
Monday, April 04, 2011
Ha az Activity-t csak Landscape akarjuk latni
Akkor az onCreate(Bundle savedInstances)-be kell beleirni ezt:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
mondjuk a a setContentView(..) ele.
Persze mas screenOrientation-t is valaszthatunk.
Tuesday, March 29, 2011
startActivityForResult-nal a requestCode nem lehet negativ
Pontosabban lehet, de: "Using negative requestCode is the same as calling startActivity(Intent) (the activity is not launched as a sub-activity)." Azaz nem fog meghivodni az onActivityResult(..)
Monday, March 28, 2011
Thursday, March 24, 2011
Android: masik Activity megnyitasa
Intent myIntent = new Intent();
myIntent.setClassName(packageName, className);
startActivity(myIntent);
myIntent.setClassName(packageName, className);
startActivity(myIntent);
Ha pedig parametereket akarunk atadni, akkor meg a startActivity elott:
myIntent.putExtra("name", "John Doe");
amit a masik oldalon (mondjuk az onCreate-ben) igy kapunk meg:
Bundle extras = getIntent().getExtras();
if (null != extras) {
String name = extras.getString("name");
}
Sokmindent at lehet adni extrakban, de object-et nem. Ezt ki kell parsolni mondjuk egy stringtombbe vagy egy json-ba (GSON).
Itt viszont azt irjak, hogy legjobb, ha Parcelable az object-unk, mert azt at lehet adni extra-kent es sokkal gyorsabb mint a parsolgatas.
Ha pedig vissza is akarunk adni valamit akkor:
- startActivityForResult(Intent, int) a sima startActivity(Intent) helyett
- a masik Activity-ben setResult(int)
Create new Activity in Eclipse
Vagy new Class.. vagy pedig:
- Double click on AndroidManifest.xml in the package explorer.
- Click on the "Application" tab of the manifest editor
- Click on "Add.." under the "Application Nodes" heading (bottom left of the screen)
- Choose Activity from the list in the dialog that pops up (if you have the option, you want to create a new top-level element)
- Click on the "Name*" link under the "Attributes for" header (bottom right of the window) to create a class for the new activity.
Subscribe to:
Posts (Atom)