1.Creating new Activity
Right click on package name => new => Class . Give name set base class of this is Activity.
Create the view by adding new xml in layout folder and call setContentView() from onCreate() of new activity.
Add the entry of this new activity in the androidmanifest.xml file.
2. Launching one activity from another
Use intent to launch one activity from another .
Ex:- Here NextActivity is class which belongs to new activity going to launch
Intent i = new Intent(this, NextActivity.class);
startActivity(i);
3.Getting click event
If the view is clickable then you can add method directly in layout ie. android:onClick=“methodName” Then the declaration of this method will be like this public void methodName(View view) {}
Some view are by default clickable (button) but some them are not (textview) to make them clickable add this property android:clickable="true"
No comments:
Post a Comment