Flights search screen with Android source code.

Rohan Surve
5 min readNov 5, 2019

--

Step 01 :

Create a new project in Android Studio from the File ⇒ New Project. As it prompts you to select the default activity, select Empty Activity and proceed.

Name your project as per your convenience and click finish.

Download this res.zip and add them to your project res folder. This file contains a few drawable images and font folder required for this app.

Step 02 :

Go to the build Gradle and do the needful changes as follows.

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.android.support:design:29.0.2'
implementation 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
implementation 'de.hdodenhof:circleimageview:3.0.1'
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'com.android.support:support-vector-drawable:29.0.2'
implementation 'com.makeramen:roundedimageview:2.3.0'
}

Open colors.xml located under res ⇒ values and add the below color values.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#1976D2</color>
<color name="colorPrimaryDark">#1565C0</color>
<color name="colorAccent">#FDD835</color>
<color name="transparent">#00000000</color>
<color name="white">#ffffff</color>
<color name="grayTxt">#8c8c8c</color>
<color name="blue">#344ff4</color>
</resources>

Open strings.xml located under res ⇒ values and add the below values.

<resources>
<string name="app_name">Flights_search</string>
<string name="from">From</string>
<string name="ny">NY</string>
<string name="new_york">New York</string>
<string name="to">To</string>
<string name="hnd">HND</string>
<string name="tokyo_haneda">Tokyo Haneda</string>
<string name="depart">Depart</string>
<string name="type">Type</string>
<string name="adults">Adults</string>
<string name="_01">01</string>
<string name="premium_economy">Premium Economy</string>
<string name="business_clas">Business Clas</string>
<string name="economy">Economy</string>
<string name="first_class">First Class</string>
<string name="children">Children</string>
<string name="one_way">One way</string>

</resources>

Open styles.xml located under res ⇒ values and add the below values.

<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>

<item name="windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>

</style>

</resources>

Step 03 :

Now is the time for making the XML file. For this, Open activity_main.xml and paste the following code.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
>

<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

<include layout="@layout/toolbar_flightsearch" />

</com.google.android.material.appbar.AppBarLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>

<include layout="@layout/flight_innerlayout"/>


<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="@color/white"
android:layout_alignParentBottom="true"
>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textSize="15.4sp"
android:background="@color/blue"
android:textColor="#ffffff"
android:letterSpacing="0.02"
android:lineSpacingExtra="2.6sp"
android:gravity="center"
android:layout_gravity="center"
android:text="Search"
/>

</LinearLayout>


</RelativeLayout>





</LinearLayout>

in the above main XML, we include the flight_innerlayout XML file so below is the file code.

<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:scrollbars="none"
android:scrollingCache="true"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>



<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/layone"
android:background="@color/cardview_shadow_start_color"
android:orientation="vertical"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"

android:weightSum="2"
>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginRight="0.5dp"
android:background="@color/white"
android:layout_height="wrap_content"
android:layout_marginEnd="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="15dp"
android:textColor="#74747a"
android:lineSpacingExtra="2.6sp"
android:text="@string/from"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="2"
android:orientation="horizontal"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#131314"
android:layout_weight="1.8"
android:layout_marginLeft="15.8dp"
android:lineSpacingExtra="5sp"
android:text="@string/ny"
android:layout_marginStart="15.8dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/grayTxt"
android:layout_marginRight="15.8dp"
android:layout_weight="0.2"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:rotation="90"
android:layout_marginEnd="15.8dp"
/>
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15.4sp"
android:layout_marginLeft="15.8dp"
android:textColor="#131314"
android:layout_marginBottom="15.8dp"
android:lineSpacingExtra="2.6sp"
android:text="@string/new_york"
android:layout_marginStart="15.8dp"
/>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginLeft="0.5dp"
android:background="@color/white"
android:layout_height="wrap_content"
android:layout_marginStart="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="15dp"
android:textColor="#74747a"
android:lineSpacingExtra="2.6sp"
android:text="@string/to"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="2"
android:orientation="horizontal"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#131314"
android:layout_weight="1.8"
android:layout_marginLeft="15.8dp"
android:lineSpacingExtra="5sp"
android:text="@string/hnd"
android:layout_marginStart="15.8dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/grayTxt"
android:layout_marginRight="15.8dp"
android:layout_weight="0.2"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:rotation="90"
android:layout_marginEnd="15.8dp"
/>
</LinearLayout>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginBottom="15.8dp"
android:textColor="#131314"
android:lineSpacingExtra="2.6sp"
android:text="@string/tokyo_haneda"
android:layout_marginStart="15.8dp"
/>

</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="horizontal"
android:weightSum="2"
>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginRight="0.5dp"
android:background="@color/white"
android:layout_height="wrap_content"
android:layout_marginEnd="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#74747a"
android:lineSpacingExtra="2.6sp"
android:text="@string/depart"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="2"
android:orientation="horizontal"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#131314"
android:layout_marginBottom="15.8dp"
android:layout_weight="1.8"
android:layout_marginLeft="15.8dp"
android:lineSpacingExtra="5sp"
android:text="16.01.2018 (TUE)"
android:layout_marginStart="15.8dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/grayTxt"
android:layout_marginRight="15.8dp"
android:layout_weight="0.2"

android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:rotation="90"
android:layout_marginEnd="15.8dp"
/>
</LinearLayout>



</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginLeft="0.5dp"
android:background="@color/white"
android:layout_height="wrap_content"
android:layout_marginStart="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#74747a"
android:lineSpacingExtra="2.6sp"
android:text="Return"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="2"
android:orientation="horizontal"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#131314"
android:layout_weight="1.8"
android:layout_marginLeft="15.8dp"
android:layout_marginBottom="15.8dp"
android:lineSpacingExtra="5sp"
android:text="22.01.2018 (MON)"
android:layout_marginStart="15.8dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/grayTxt"
android:layout_marginRight="15.8dp"
android:layout_weight="0.2"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:rotation="90"
android:layout_marginEnd="15.8dp"
/>
</LinearLayout>


</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:background="@color/white"
android:orientation="horizontal"
android:weightSum="2"
>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginRight="0.5dp"
android:background="#f5f5f5"
android:layout_height="match_parent"
android:layout_marginEnd="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#74747a"
android:lineSpacingExtra="2.6sp"
android:text="Class &amp; Travellers"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="2"
android:orientation="horizontal"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#131314"

android:layout_weight="1.8"
android:layout_marginLeft="15.8dp"
android:lineSpacingExtra="5sp"
android:text="1 adult, Economy"
android:layout_marginStart="15.8dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/grayTxt"
android:layout_marginRight="15.8dp"
android:layout_weight="0.2"

android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:rotation="270"
android:layout_marginEnd="15.8dp"
/>
</LinearLayout>



</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginBottom="19.8dp"
android:layout_marginLeft="0.5dp"
android:background="@color/white"
android:layout_height="match_parent"
android:layout_marginStart="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#74747a"
android:lineSpacingExtra="2.6sp"
android:text="@string/type"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:weightSum="2"
android:orientation="horizontal"
>

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textColor="#131314"
android:layout_weight="1.8"
android:layout_marginLeft="15.8dp"

android:lineSpacingExtra="5sp"
android:text="@string/one_way"
android:layout_marginStart="15.8dp"
/>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tint="@color/grayTxt"
android:layout_marginRight="15.8dp"
android:layout_weight="0.2"
android:src="@drawable/ic_keyboard_arrow_right_black_24dp"
android:rotation="90"
android:layout_marginEnd="15.8dp"
/>
</LinearLayout>


</LinearLayout>

</LinearLayout>



</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:layout_below="@+id/layone"
android:visibility="visible"
android:layout_marginTop="10dp"
android:orientation="vertical"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="1dp"
android:orientation="horizontal"

android:weightSum="2"
>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginRight="0.5dp"
android:background="#2e3037"
android:layout_height="wrap_content"
android:layout_marginEnd="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#9b9da3"
android:lineSpacingExtra="2.6sp"
android:text="@string/adults"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="15.8dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_marginStart="15.8dp"
>

<ImageButton
android:layout_width="wrap_content"
android:layout_height="35sp"
android:layout_weight="1"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/icon_minus"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:gravity="center"
android:text="@string/_01"
android:textColor="@color/white"
android:layout_weight="1"
android:textSize="23sp"
android:layout_gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
/>

<ImageButton
android:layout_width="wrap_content"
android:layout_height="35sp"
android:layout_weight="1"
android:layout_marginRight="15.8dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/icon_plus"
android:layout_marginEnd="15.8dp"
/>

</LinearLayout>



</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_weight="1"
android:layout_marginLeft="0.5dp"
android:background="#2e3037"
android:layout_height="wrap_content"
android:layout_marginStart="0.5dp"
>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#9b9da3"
android:lineSpacingExtra="2.6sp"
android:text="@string/children"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginLeft="15.8dp"
android:layout_marginBottom="10dp"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_marginStart="15.8dp"
>

<ImageButton
android:layout_width="wrap_content"
android:layout_height="35sp"
android:layout_weight="1"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/icon_minus"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/spacing_large"
android:layout_marginRight="@dimen/spacing_large"
android:gravity="center"
android:text="00"
android:textColor="@color/white"
android:layout_weight="1"
android:textSize="23sp"
android:layout_gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
/>

<ImageButton
android:layout_width="wrap_content"
android:layout_height="35sp"
android:layout_weight="1"
android:layout_marginRight="15.8dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/icon_plus"
android:layout_marginEnd="15.8dp"
/>

</LinearLayout>


</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2e3037"
android:layout_marginTop="0.5dp"
android:layout_marginRight="0.5dp"
android:layout_marginBottom="20dp"
android:layout_weight="1"
android:orientation="vertical"
android:layout_marginEnd="0.5dp"
>



<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#9b9da3"
android:lineSpacingExtra="2.6sp"
android:text="Class"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"

android:orientation="horizontal"
>

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15.8dp"
android:src="@drawable/icon_righttick"
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15.4sp"
android:textColor="#ffffff"
android:layout_marginLeft="20dp"
android:lineSpacingExtra="2.6sp"
android:text="@string/economy"
android:layout_marginStart="20dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15.4sp"
android:textColor="#9b9da3"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginBottom="20dp"
android:lineSpacingExtra="2.6sp"
android:text="@string/business_clas"
android:layout_marginStart="20dp"
/>


</LinearLayout>


</LinearLayout>

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2e3037"
android:layout_marginTop="0.5dp"
android:layout_marginLeft="0.5dp"
android:layout_weight="1"
android:layout_marginBottom="20dp"
android:orientation="vertical"
android:layout_marginStart="0.5dp"
>




<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13.4sp"
android:layout_marginLeft="15.8dp"
android:layout_marginTop="20dp"
android:textColor="#9b9da3"
android:lineSpacingExtra="2.6sp"
android:text=""
android:layout_marginStart="15.8dp"
/>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
>



<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15.4sp"
android:textColor="#9b9da3"
android:layout_marginLeft="20dp"
android:lineSpacingExtra="2.6sp"
android:text="@string/premium_economy"
android:layout_marginStart="20dp"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15.4sp"
android:textColor="#9b9da3"
android:layout_marginTop="30dp"
android:layout_marginLeft="20dp"
android:layout_marginBottom="20dp"
android:lineSpacingExtra="2.6sp"
android:text="@string/first_class"
android:layout_marginStart="20dp"
/>


</LinearLayout>


</LinearLayout>



</LinearLayout>

</LinearLayout>



</LinearLayout>

</LinearLayout>

</androidx.core.widget.NestedScrollView>

Step 04 :

Now the XML part is done, moving to the next we have to create the Menu folder in resources.

Right-click on the res folder and create a new Android resource directory. and in that folder create one menu resource file. and write the following code. I created menu_basic.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>



<item
android:orderInCategory="100"
android:title="Settings"
app:showAsAction="never"
/>
</menu>

Step 05 :

Open the Mainactivity.java class file and write the following code.

package com.example.flights_search;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(R.drawable.ic_menu_white_24dp);
setSupportActionBar(toolbar);
getSupportActionBar().setTitle("Book a Flight");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_basic, menu);


return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == android.R.id.home) {
finish();
} else {
Toast.makeText(getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
}
return super.onOptionsItemSelected(item);
}
}

Now run the app and see the output, you will see the awesome Flights search screen with Android source code. for your next android project.

So that’s all for this Flights search screen with Android source code Tutorial. If you are having any confusion or queries please do comment. Thank You.

--

--