Posts

Showing posts with the label Android - Navigation Tutorial

Android - Navigation Tutorial

Image
In this chapter, we will see that how you can provide navigation forward and backward between an application. We will first look at how to provide up navigation in an application. Providing Up Navigation The up navigation will allow our application to move to previous activity from the next activity. It can be done like this. To implement Up navigation, the first step is to declare which activity is the appropriate parent for each activity. You can do it by specifying parentActivityName  attribute in an activity. Its syntax is given below − android:parentActivityName="com.example.test.MainActivity" After that you need to call  setDisplayHomeAsUpEnabled  method of getActionBar()  in the onCreate method of the activity. This will enable the back button in the top action bar. getActionBar (). setDisplayHomeAsUpEnabled ( true ); The last thing you need to do is to override  onOptionsItemSelected  method. when the user presses it, your activity re...