Saturday, July 10, 2021

Tips Tricks for Android Phone

Tips & Tricks for Android Phone is a free android app and Collection of Tips and Tricks related to using your android mobile device like a boss and getting the most out of it. All Includes Information and Help for Android Phones and Tablets Tips & Tricks Optimizing Device Performance Memory Speed Data Usage and more. How to use your backup saved on the internal storage of your mobile device or SD Card or saved Google drive and how to restore it.

Some topics about Android tricks:

+ How to install the app

+ Troubleshooting of Android phones

+ Some of the latest information about the Android operating system

+ Introducing some good apps for android phones

+ Handling speed increase of the phone

+ Troubleshooting internet problems

+ Speed up memory processing

+ Other Troubleshooting

Features of the app:

+ Share with you good tips for Android

+ You can download the application by following the link in the article

+ Follow the article and can share the article with friends via social networks.

+ Search for tips in the app by title

Thank you for always using our application, please comment on our tips application so that we will update to make your experience better. Thanks very much.

Download Tips Trick for Android

How to Constraint Layout Vertical Align Center

ConstraintLayout is a layout on Android that gives you adaptable and flexible ways to create views for your apps. ConstraintLayout , which is now the default layout in Android Studio, gives you many ways to place objects. You can constrain them to their container, to each other or to guidelines

How to Constraint Layout Vertical Align Center

It's possible to set the center aligned view as an anchor for other views. In the example below "@+id/stat_2" centered horizontally in parent and it serves as an anchor for other views in this layout.

<android.support.constraint.ConstraintLayout 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">


    <TextView

        android:id="@+id/stat_1"

        android:layout_width="80dp"

        android:layout_height="wrap_content"

        android:layout_marginEnd="8dp"

        android:gravity="center"

        android:maxLines="1"

        android:text="10"

        android:textColor="#777"

        android:textSize="22sp"

        app:layout_constraintTop_toTopOf="@+id/stat_2"

        app:layout_constraintEnd_toStartOf="@+id/divider_1" />


    <TextView

        android:id="@+id/stat_detail_1"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:text="Streak"

        android:textColor="#777"

        android:textSize="12sp"

        app:layout_constraintTop_toBottomOf="@+id/stat_1"

        app:layout_constraintStart_toStartOf="@+id/stat_1"

        app:layout_constraintEnd_toEndOf="@+id/stat_1" />


    <View

        android:id="@+id/divider_1"

        android:layout_width="1dp"

        android:layout_height="0dp"

        android:layout_marginEnd="16dp"

        android:background="#ccc"

        app:layout_constraintTop_toTopOf="@+id/stat_2"

        app:layout_constraintEnd_toStartOf="@+id/stat_2"

        app:layout_constraintBottom_toBottomOf="@+id/stat_detail_2" />


    <TextView

        android:id="@+id/stat_2"

        android:layout_width="80dp"

        android:layout_height="wrap_content"

        android:gravity="center"

        android:maxLines="1"

        android:text="243"

        android:textColor="#777"

        android:textSize="22sp"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintBottom_toBottomOf="parent" />


    <TextView

        android:id="@+id/stat_detail_2"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:maxLines="1"

        android:text="Calories Burned"

        android:textColor="#777"

        android:textSize="12sp"

        app:layout_constraintTop_toBottomOf="@+id/stat_2"

        app:layout_constraintStart_toStartOf="@+id/stat_2"

        app:layout_constraintEnd_toEndOf="@+id/stat_2" />


    <View

        android:id="@+id/divider_2"

        android:layout_width="1dp"

        android:layout_height="0dp"

        android:layout_marginStart="16dp"

        android:background="#ccc"

        app:layout_constraintBottom_toBottomOf="@+id/stat_detail_2"

        app:layout_constraintStart_toEndOf="@+id/stat_2"

        app:layout_constraintTop_toTopOf="@+id/stat_2" />


    <TextView

        android:id="@+id/stat_3"

        android:layout_width="80dp"

        android:layout_height="wrap_content"

        android:layout_marginStart="8dp"

        android:gravity="center"

        android:maxLines="1"

        android:text="3200"

        android:textColor="#777"

        android:textSize="22sp"

        app:layout_constraintTop_toTopOf="@+id/stat_2"

        app:layout_constraintStart_toEndOf="@+id/divider_2" />


    <TextView

        android:id="@+id/stat_detail_3"

        android:layout_width="wrap_content"

        android:layout_height="wrap_content"

        android:maxLines="1"

        android:text="Steps"

        android:textColor="#777"

        android:textSize="12sp"

        app:layout_constraintTop_toBottomOf="@+id/stat_3"

        app:layout_constraintStart_toStartOf="@+id/stat_3"

        app:layout_constraintEnd_toEndOf="@+id/stat_3" />


</android.support.constraint.ConstraintLayout>

If you have a ConstraintLayout with some size, and a child View with some smaller size, you can achieve centering by constraining the child's two edges to the same two edges of the parent. That is, you can write:

app:layout_constraintTop_toTopOf="parent"

app:layout_constraintBottom_toBottomOf="parent"

or

app:layout_constraintLeft_toLeftOf="parent"

app:layout_constraintRight_toRightOf="parent"

Update

Below is XML that achieves your desired UI with no nesting of views and no Guidelines (though guidelines are not inherently evil).

<android.support.constraint.ConstraintLayout

    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="wrap_content"

    android:background="#eee">


    <TextView

        android:id="@+id/title1"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:layout_marginBottom="12dp"

        android:gravity="center"

        android:textColor="#777"

        android:textSize="22sp"

        android:text="10"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toLeftOf="@+id/divider1"

        app:layout_constraintBottom_toBottomOf="parent"/>


    <TextView

        android:id="@+id/label1"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:gravity="center"

        android:textColor="#777"

        android:textSize="12sp"

        android:text="Streak"

        app:layout_constraintTop_toBottomOf="@+id/title1"

        app:layout_constraintLeft_toLeftOf="parent"

        app:layout_constraintRight_toLeftOf="@+id/divider1"/>


    <View

        android:id="@+id/divider1"

        android:layout_width="1dp"

        android:layout_height="55dp"

        android:layout_marginTop="12dp"

        android:layout_marginBottom="12dp"

        android:background="#ccc"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constraintLeft_toRightOf="@+id/title1"

        app:layout_constraintRight_toLeftOf="@+id/title2"

        app:layout_constraintBottom_toBottomOf="parent"/>


    <TextView

        android:id="@+id/title2"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:layout_marginBottom="12dp"

        android:gravity="center"

        android:textColor="#777"

        android:textSize="22sp"

        android:text="243"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constraintLeft_toRightOf="@+id/divider1"

        app:layout_constraintRight_toLeftOf="@+id/divider2"

        app:layout_constraintBottom_toBottomOf="parent"/>


    <TextView

        android:id="@+id/label2"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:gravity="center"

        android:textColor="#777"

        android:textSize="12sp"

        android:text="Calories Burned"

        app:layout_constraintTop_toBottomOf="@+id/title2"

        app:layout_constraintLeft_toRightOf="@+id/divider1"

        app:layout_constraintRight_toLeftOf="@+id/divider2"/>


    <View

        android:id="@+id/divider2"

        android:layout_width="1dp"

        android:layout_height="55dp"

        android:layout_marginTop="12dp"

        android:layout_marginBottom="12dp"

        android:background="#ccc"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constraintLeft_toRightOf="@+id/title2"

        app:layout_constraintRight_toLeftOf="@+id/title3"

        app:layout_constraintBottom_toBottomOf="parent"/>


    <TextView

        android:id="@+id/title3"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:layout_marginBottom="12dp"

        android:gravity="center"

        android:textColor="#777"

        android:textSize="22sp"

        android:text="3200"

        app:layout_constraintTop_toTopOf="parent"

        app:layout_constraintLeft_toRightOf="@+id/divider2"

        app:layout_constraintRight_toRightOf="parent"

        app:layout_constraintBottom_toBottomOf="parent"/>


    <TextView

        android:id="@+id/label3"

        android:layout_width="0dp"

        android:layout_height="wrap_content"

        android:gravity="center"

        android:textColor="#777"

        android:textSize="12sp"

        android:text="Steps"

        app:layout_constraintTop_toBottomOf="@+id/title3"

        app:layout_constraintLeft_toRightOf="@+id/divider2"

        app:layout_constraintRight_toRightOf="parent"/>

</android.support.constraint.ConstraintLayout>

Friday, July 9, 2021

Top 5 best gaming Phones

Top 5 best gaming Phones

 For playing High Quality Games we should required a High Quality Mobiles, so below is list of Top 5 best gaming mobile phone with prices. 


1. Asus ROG Phone

 5

The best gaming phone



Display: 6.78" FHD+ AMOLED, 144Hz | Processor: Snapdragon 888 | RAM: 8GB | Storage: 128GB | Rear camera: 64+13+5MP | Front camera: 24MP | Battery: 6000mAh | Charging: 30W (supports 65W) | OS: Android 11 | Weight: 242g | Thickness: 10.3mm


■Remarkable performance

✙Neat built-in gaming features

✥Great display and speakers

➹Bulky

❖No 65W fast charger in the box

★Still no telephoto lens

The Asus ROG 5 is the best gaming smartphone you can buy with design, features, and software perks that augment the playing experience. Incremental improvements on its predecessor make it a superior choice that makes the phone appealing to non-gamers as well, from its good screen to great speakers. 


The ROG Phone 5 comes in three variants - the ROG Phone 5, ROG Phone 5 Pro, and ROG Phone 5 Ultimate. On paper specs across all three variants are the same with the only difference coming in the form of RAM and storage. The major change, however, comes in terms of the design. The Pro and Ultimate come with a monochromatic design while the vanilla ROG Phone 5 offers an RGB logo. 



ROG Phone 5 vs ROG Phone 5 Pro vs ROG Phone 5 Ultimate

ROG Phone 5 ROG Phone 5 Pro ROG Phone 5 Ultimate

Processor Snapdragon 888 Snapdragon 888 Snapdragon 888

RAM 8/12GB 16GB 18GB

Storage 128/256GB 512GB 512GB

Design (back) Monochromatic RGB RGB

Price Rs 49,999 onwards Rs 69,999 Rs 79,999

The phone also comes with a 6.78-inch Full HD+ AMOLED display with a 144Hz refresh rate and all three phones are powered by a Snapdragon 888 processor with up to 18GB of RAM. In addition to the cooling technology inside, you can also get the additional AeroActive Cooler 5 fan (included in the box for Pro and Ultimate).


At the end of the day, It’s still a pricey handset with notable camera shortcomings compared to rival flagships, but the Asus ROG 5 is a gaming phone first and just for that, there is no competition at all.


2. iQoo 7 Legend



Display: 6.62" FHD+, AMOLED, 120Hz | Processor: Snapdragon 888 | RAM: 8/12GB | Storage: 128/256GB | Battery: 4,000mAh, 66W | Rear camera: 48+13+13MP | Front camera: 16MP | OS: Android 11 | Weight: 209.5g | Thickness: 8.7mm



✙Performance

■Display

✥Stereo speakers

❖Battery

✾Software

iQoo made its comeback to India after a year and launched the iQoo 7 series with the top-of-the-line iQoo 7 Legend which is basically the BMW Edition from China. The iQoo 7 Legend is also one of the cheapest phones with a Snapdragon 888 processor. There’s also a 4,096sqmm vapor chamber to keep the thermals in check. The device is made up of pure white matte surface AG matte glass on the back along with a race track-inspired design. 


The Indian variant misses out on the 125W fast charging, offering a 66W Flash Charger instead. It is claimed to take the 4,000mAh battery to full in about 22 minutes. You also get “enhanced” UFS 3.1 storage, LPDDR5 RAM, and virtual RAM. On the front is a 6.62-inch AMOLED display with Full HD+ resolution, 120Hz refresh rate, and 300Hz touch sampling rate. It also offers HDR10+ certification, 1,000Hz instant touch sampling, and an in-display fingerprint scanner.


In terms of optics, the iQoo 7 Legend sports an optically stabilized 48MP camera(Sony IMX 598), a 13MP ultra-wide lens that doubles as a macro shooter, and a 13MP portrait lens with a focal length of 50mm. For selfies, there’s a 16MP camera on the front


Price At Amazone - ₹20, 999


3. Xiaomi Mi 11X



Display: 6.67" FHD+, Super AMOLED, 120Hz | Processor: Snapdragon 870 | RAM: 6/8GB | Storage: 128GB | Rear camera: 48+8+5MP | Front camera: 20MP | Battery: 4520mAh | Charging: 33W | OS: Android 11 | Weight: 196g | Thickness: 7.8mm

₹29,999
VIEW AT AMAZON
₹29,999
View at Amazon
Aggressive price
E4 AMOLED panel
Cameras
MIUI needs some work
No the fastest charging
The Xiaomi Mi 11X is a great option for those who don’t want to spend over Rs 40,000 for a flagship gaming device. The Mi 11X powered by Snapdragon 870 and paired with LPDDR5 RAM, UFS 3.1 storage, and an excellent E4 AMOLED panel with a 120Hz refresh rate is probably the best you can ask from a phone priced around Rs 30,000. 

Not only it can perform in terms of the game, but the phone is also a good all-round device in the mid-range segment. CoD Mobile, Genshin Impact, Garena FreeFire all games run at the highest graphics settings. In terms of cameras, the device comes with a 48MP main camera which is above average. For those who can spend Rs 10,000 more, the Mi 11X with Snapdragon 888 and 108MP camera is also a good buy


4. Samsung Galaxy S20 FE 5G



The best of Samsung

Display: 6.7" FHD+, Super AMOLED, 120Hz | Processor: Snapdragon 865 | RAM: 8GB | Storage: 128GB | Rear camera: 12+8+12MP | Front camera: 32MP | Battery: 4500mAh | Charging: 25W | OS: Android 11 | Weight: 190g | Thickness: 8.4mm

₹47,999
VIEW AT AMAZON
₹47,999
View at Amazon
Capable cameras
Display
Performance
IP rating and wireless charging
Slow charging
Average battery life
Samsung and Snapdragon are always a rare combo for the Indian market and we have one with the same in the flagship segment with the launch of Galaxy S20 FE 5G. Although it sports a last-gen Snapdragon 865 processor, the Galaxy S20 FE 5G is a good buy especially if you are a loyal Samsung fan. Firstly, the performance is improved and is far more power-efficient thanks to the Snapdragon chipset, the gaming performance is also up to the flagship level. 

The heating issues which we had on the Exynos variant are also gone for good. However, the slow charging is still a pain. But, if you can leave that behind, you get a pretty great smartphone from a top brand. Apart from that, you also get some premium features like an IP68 rating, wireless charging, and a cool design. The device sports a good 120Hz AMOLED panel and a reliable 12MP triple camera setup. 


5. Poco X3 Pro



The best budget gaming phone

Display: 6.67" FHD+, LCD, 120Hz | Processor: Snapdragon 860 | RAM: 6/8GB | Storage: 128GB | Battery: 5160mAh, 33W | Rear camera: 48+8+2+2MP | Front camera: 20MP | OS: Android 11, MIUI 12 | Weight: 213g | Thickness: 9.4mm

Excellent performance
Battery life
Camera
Relatively slow charging
Bulky
The best budget gaming phone, the Poco X3 Pro’s buzz is basically created by the Qualcomm processor. The star of the show here is the Snapdragon 860 processor that performs exceptionally well, under-cutting the rivals by a fair margin. The Poco X3 Pro also comes with LiquidCool Technology 1.0 Plus to keep thermals under check. 

Thanks to the fast storage and flagship-grade processor, the Poco X3 flies through anything you throw at it δΈ€ be it as simple as opening an app to playing high-end intense games. On top of the top-end performance, the 120Hz smooth screen refresh rate also plays a part in making the overall experience buttery smooth. 

As for the gaming, we tried out games like CoD Mobile, Beach Buggy Racing 2, and Asphalt which ran smoothly on the highest graphics possible. The Genshin Impact game ran on medium settings best while we had a bit of stutter with the highest setting. During the gaming session, the phone heats up quite a bit, but it can be handled. For under Rs 20,000, the Poco X3 Pro won’t disappoint you as a gaming phone

Price -  ₹19, 990

Copyright ©

Images are dervied from 
* krazy games 001 ( krazy gamer 2.0 { Mohd Dayan} ) 
* Hindustan tech. Com 
*kalinga TV 
*techadvisor.com
*financial express. Com
*india today 

PROMOTION 



Thanks πŸ’• for Visiting
 






Thursday, July 8, 2021

Error: Cannot fit requested classes in a single dex file # methods

I encountered a multiDex problem when quoting the autobahn framework. After looking for relevant information and browsing the explanations of the great gods on the Internet, I solved this problem. Record the problem solving process here.

First of all, let’s roughly talk about why this problem occurs. The android project will compile java files into class files during the compilation process, and then package the class files into dex files. By default, only one dex file is packaged during the packaging process, but a single dex file. The number of methods in the file cannot exceed 65536. When we reference a bunch of dependencies and third-party libraries, after the number of methods exceeds, packaged into a single dex file will compile an error, so it needs to be packaged into multiple dex files, that is multiDexEnable.

Step 1: introduce dependencies

implementation 'com.android.support:multidex:1.0.3'

Or

implementation 'androidx.multidex:multidex:2.0.0'

Step 2: Add configuration items

Add the configuration item multiDexEnable true under android-->defaultConfig of the main project, as shown in the following figure:

   defaultConfig {

        applicationId ""

        minSdkVersion 16

        targetSdkVersion 30

        versionCode 1

        versionName "1.1"

        multiDexEnabled true

}

Step 3. Introduce the Application class

If there is no Application class in the original project, create a new Application class to inherit the MultiDexApplication class, and then reference this Application in the Manifest file.

If there is already an Application class in the original project, which has already inherited other classes, due to java's single inheritance mode, MultiDexApplication can no longer be inherited, and it can be solved by rewriting the attachBaseContext method

@Override

protected void attachBaseContext(android.content.Context base) {

   super.attachBaseContext(base);

   android.support.multidex.MultiDex.install(this);

}

Some netizens reported that after the above steps, there is no error when running on version 5.0 or higher, but it will crash in version 4.4. Here are the relevant suggestions (only recorded, not tested, no android4.4 device at hand)

Add configuration in build.gradle file, same level directory as buildTypes and defaultConfig configuration

dexOptions{

    preDexLibraries = false

}

Wednesday, July 7, 2021

How To Play GTA 5 On Low End Laptop without Graphics Card 2021

 How To Play GTA 5 On Low-End Laptop without Graphics Card 2021

Download N0W


Download Link$

1. Commandline 2. Low-End mod 3. OpenIV

4. Scripthookv


Tutorial Video



Tuesday, July 6, 2021

How to create different graphs in Android

A series of destinations can be grouped into a nested graph within a parent navigation graph called the root graph. Nested graphs are useful to organize and reuse sections of your app’s UI, such as a self-contained login flow.

The nested graph encapsulates its destinations. As with a root graph, a nested graph must have a destination identified as the start destination. Destinations outside of the nested graph, How to create different graphs in Android such as those on the root graph, access the nested graph only through its start destination.

Step 1: Create a new project in Example Android, go to File ⇒ New Project and fill all required details to create a new project.

How to create different graphs in Android

Step 2: Add the following dependency in the build.gradle (Module: app)

implementation 'com.jjoe64:graphview:4.2.1'

Step 3: Add the following code to res/layout/activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   android:orientation="vertical"

   android:padding="16sp"

   tools:context=".MainActivity">

   <com.jjoe64.graphview.GraphView

      android:layout_width="match_parent"

      android:layout_height="match_parent"

      android:id="@+id/graph" />

</LinearLayout>

Step 4: Add the following code to src/MainActivity.java

public class MainActivity extends AppCompatActivity {

   @Override

   protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

      GraphView graph = findViewById(R.id.graph);

      LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[] {

         new DataPoint(0, 1),

         new DataPoint(1, 5),

         new DataPoint(2, 3),

         new DataPoint(3, 2),

         new DataPoint(4, 6)

      });

      graph.addSeries(series);

   }

}

Step 4: Add the following code to androidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

   package="app.com.sample">

   <application

      android:allowBackup="true"

      android:icon="@mipmap/ic_launcher"

      android:label="@string/app_name"

      android:roundIcon="@mipmap/ic_launcher_round"

      android:supportsRtl="true"

      android:theme="@style/AppTheme">

      <activity android:name=".MainActivity">

         <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>

      </activity>

   </application>

</manifest>

How to create TextToSpeech in an android

How to create TextToSpeech in an android

A TextToSpeech instance can only be used to synthesize text once it has completed its initialization. Implement the TextToSpeech.OnInitListener to be notified of the completion of the initialization.

When you are done using the TextToSpeech instance, call the shutdown() method to release the native resources used by the TextToSpeech engine. Apps targeting Android 11

Step 1 Create a new project in Android Example, go to File ⇒ New Project and fill all required details to create a new project.

How to create TextToSpeech in an android

Step 2 Add the following code to res/layout/activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   android:orientation="vertical"

   android:gravity="center"

   tools:context=".MainActivity">

   <EditText

      android:id="@+id/editText"

      android:layout_width="match_parent"

      android:layout_height="wrap_content"

      android:layout_marginBottom="16dp"

      android:hint="Enter Text" />

   <TextView

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:text="Pitch"

      android:textSize="16sp" />

   <SeekBar

      android:id="@+id/seekBarPitch"

      android:layout_width="200dp"

      android:layout_height="wrap_content"

      android:progress="50" />

   <TextView

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:text="Speed"

      android:textSize="16sp" />

   <SeekBar

      android:id="@+id/seekBarSpeed"

      android:layout_width="200dp"

      android:layout_height="wrap_content"

      android:layout_marginBottom="16dp"

      android:progress="50" />

   <Button

      android:id="@+id/btnSpeak"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_gravity="center_horizontal"

      android:enabled="false"

      android:text="Say it!" />

</LinearLayout>

Step 3 Add the following code to src/MainActivity.java

public class MainActivity extends AppCompatActivity {

   private TextToSpeech textToSpeech;

   private EditText editText;

   private SeekBar seekBarPitch;

   private SeekBar seekBarSpeed;

   private Button buttonSpeak;

   @Override

   protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

      buttonSpeak = findViewById(R.id.btnSpeak);

      textToSpeech = new TextToSpeech(this, new TextToSpeech.OnInitListener() {

         @Override

         public void onInit(int status) {

            if (status == TextToSpeech.SUCCESS) {

               int result = textToSpeech.setLanguage(Locale.ENGLISH);

               if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED) {

                  Log.e("TextToSpeech", "Language not supported");

               } else {

                  buttonSpeak.setEnabled(true);

               }

            } else {

               Log.e("TextToSpeech", "Initialization failed");

            }

         }

      });

      editText = findViewById(R.id.editText);

      seekBarPitch = findViewById(R.id.seekBarPitch);

      seekBarSpeed = findViewById(R.id.seekBarSpeed);

      buttonSpeak.setOnClickListener(new View.OnClickListener() {

         @Override

         public void onClick(View v) {

            speak();

         }

      });

   }

   private void speak() {

      String text = editText.getText().toString();

      float pitch = (float) seekBarPitch.getProgress() / 50;

      if (pitch < 0.1) pitch = 0.1f;

      float speed = (float) seekBarSpeed.getProgress() / 50;

      if (speed < 0.1) speed = 0.1f;

      textToSpeech.setPitch(pitch);

      textToSpeech.setSpeechRate(speed);

      textToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, null);

   }

   @Override

   protected void onDestroy() {

      if (textToSpeech != null) {

         textToSpeech.stop();

         textToSpeech.shutdown();

      }

      super.onDestroy();

   }

}

Step 4: Add the following code to androidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">

   <application

      android:allowBackup="true"

      android:icon="@mipmap/ic_launcher"

      android:label="@string/app_name"

      android:roundIcon="@mipmap/ic_launcher_round"

      android:supportsRtl="true"

      android:theme="@style/AppTheme">

      <activity android:name=".MainActivity">

         <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>

      </activity>

   </application>

</manifest>

How to Create a Tab Layout in Android

How to Create a Tab Layout in Android

A layout defines the structure for a user interface in your app, such as in an activity. All elements in the layout are built using a hierarchy of View and ViewGroup objects. A View usually draws something the user can see and interact with. Whereas a ViewGroup is an invisible container that defines the layout structure for View and other ViewGroup

Step 1: Create a new project in Android Example, go to File ⇒ New Project and fill all required details to create a new project.

Tab Layout in Android

Step 2: Add the following dependency to create a tab layout

implementation 'com.android.support:design:28.0.0'

Step 3: Add the following code to res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout

   xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   tools:context=".MainActivity">

   <android.support.design.widget.TabLayout

      android:id="@+id/tabLayout"

      android:layout_width="match_parent"

      android:layout_height="wrap_content"

      android:background="#1db995">

   </android.support.design.widget.TabLayout>

   <android.support.v4.view.ViewPager

      android:id="@+id/viewPager"

      android:layout_width="wrap_content"

      android:layout_height="wrap_content"

      android:layout_below="@id/tabLayout"

      android:layout_centerInParent="true"

      android:layout_marginTop="100dp"

      tools:layout_editor_absoluteX="8dp" />

</RelativeLayout>

Step 4: Add the following code to src/MainActivity.java

public class MainActivity extends AppCompatActivity {

   TabLayout tabLayout;

   ViewPager viewPager;

   @Override

   protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

      tabLayout = findViewById(R.id.tabLayout);

      viewPager = findViewById(R.id.viewPager);

      tabLayout.addTab(tabLayout.newTab().setText("Football"));

      tabLayout.addTab(tabLayout.newTab().setText("Cricket"));

      tabLayout.addTab(tabLayout.newTab().setText("NBA"));

      tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

      final MyAdapter adapter = new MyAdapter(this,getSupportFragmentManager(),

      tabLayout.getTabCount());

      viewPager.setAdapter(adapter);

      viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

      tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

         @Override

         public void onTabSelected(TabLayout.Tab tab) {

            viewPager.setCurrentItem(tab.getPosition());

         }

         @Override

         public void onTabUnselected(TabLayout.Tab tab) {

         }

         @Override

         public void onTabReselected(TabLayout.Tab tab) {

         }

      });

   }

}

Step 5: Create a java class(MyAdapter.java)

class MyAdapter extends FragmentPagerAdapter {

   Context context;

   int totalTabs;

   public MyAdapter(Context c, FragmentManager fm, int totalTabs) {

      super(fm);

      context = c;

      this.totalTabs = totalTabs;

   }

   @Override

   public Fragment getItem(int position) {

      switch (position) {

         case 0:

            Football footballFragment = new Football();

         return footballFragment;

         case 1:

            Cricket cricketFragment = new Cricket();

         return cricketFragment;

         case 2:

            NBA nbaFragment = new NBA();

         return nbaFragment;

         default:

         return null;

      }

   }

   @Override

   public int getCount() {

      return totalTabs;

   }

}

Step 6: Now create the fragments

Fragment Football.java

public class Football extends Fragment {

   public Football() {

      // Required empty public constructor

   }

   @Override

   public View onCreateView(LayoutInflater inflater, ViewGroup container,

    Bundle savedInstanceState) {

      return inflater.inflate(R.layout.fragment_football, container, false);

   }

}

Layout fragment.xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   tools:context=".Football">

   <!-- TODO: Update blank fragment layout -->

   <TextView

      android:layout_width="match_parent"

      android:layout_height="match_parent"

      android:textAlignment="center"

      android:text="Football Fragment"

      android:textSize="16sp"

      android:textStyle="bold"/>

</FrameLayout>

Fragment Cricket.java

public class Cricket extends Fragment {

   public Cricket() {

      // Required empty public constructor

   }

   @Override

   public View onCreateView(LayoutInflater inflater, ViewGroup container,

    Bundle savedInstanceState) {

      return inflater.inflate(R.layout.fragment_cricket, container, false);

   }

}

Layout cricketFragment.xml

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   tools:context=".Cricket">

   <TextView

      android:layout_width="match_parent"

      android:layout_height="match_parent"

      android:textAlignment="center"

      android:text="Cricket Fragment"

      android:textSize="16sp"

      android:textStyle="bold"/>

</FrameLayout>

Create Fragment NBA.java

public class NBA extends Fragment {

   public NBA() {

      // Required empty public constructor

   }

   @Override

   public View onCreateView(LayoutInflater inflater, ViewGroup container,

    Bundle savedInstanceState) {

      return inflater.inflate(R.layout.fragment_nb, container, false);

   }

}

Layout fragment

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"

   xmlns:tools="http://schemas.android.com/tools"

   android:layout_width="match_parent"

   android:layout_height="match_parent"

   tools:context=".NBA">

   <!-- TODO: Update blank fragment layout -->

   <TextView

      android:layout_width="match_parent"

      android:layout_height="match_parent"

      android:textAlignment="center"

      android:text="NBA Fragment"

      android:textSize="16sp"

      android:textStyle="bold"/>

</FrameLayout>

Step 7:  Add the following code to androidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

   package="app.com.sample">

   <application

      android:allowBackup="true"

      android:icon="@mipmap/ic_launcher"

      android:label="@string/app_name"

      android:roundIcon="@mipmap/ic_launcher_round"

      android:supportsRtl="true"

      android:theme="@style/AppTheme">

      <activity android:name=".MainActivity">

         <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>

      </activity>

   </application>

</manifest>

How to create a WebView in an Android App using Kotlin

Another scenario in which WebView can help is if your app provides data to the user that always requires an Internet connection to retrieve data, such as email. In this case, you might find that it's easier to build a WebView in your Android app that shows a web page with all the user data, rather than performing a network request, then parsing the data and rendering it in an Android layout. Instead, you can design a web page that's tailored for Android devices and then implement a WebView in your Android app that loads the web page.

This document shows you how to get started with How to create a WebView in an Android App using Kotlin do some additional things, such as handle page navigation and bind JavaScript from your web page to client-side code in your Android app

Step 1 − Create a new project in Android Studio, go to File ? New Project and fill all required details to create a new project.

Step 2: Create layout

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"

   android:id = "@+id/parent"

   xmlns:tools = "http://schemas.android.com/tools"

   android:layout_width = "match_parent"

   android:layout_height = "match_parent"

   tools:context = ".MainActivity">

   <WebView

      android:id="@+id/webView"

      android:layout_width="match_parent"

      android:layout_height="match_parent">

   </WebView>

</RlativeLayout>

Step 3: Add the following code to src/MainActivity.kt

class MainActivity : AppCompatActivity() {

   private val webView: WebView? = null

   override fun onCreate(savedInstanceState: Bundle?) {

      super.onCreate(savedInstanceState)

      setContentView(R.layout.activity_main)

      title = "KotlinApp"

      val webView = findViewById<WebView>(R.id.webView)

      webView.webViewClient = WebViewClient()

      webView.loadUrl("https://www.google.com")

      val webSettings = webView.settings

      webSettings.javaScriptEnabled = true

   }

   override fun onBackPressed() {

      if (webView!!.canGoBack()) {

         webView.goBack()

      } else {

         super.onBackPressed()

      }

   }

}

Step 4: Add the following code to androidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.myapplication">

   <application

   android:allowBackup="true"

   android:icon="@mipmap/ic_launcher"

   android:label="@string/app_name"

   android:roundIcon="@mipmap/ic_launcher_round"

   android:supportsRtl="true"

   android:theme="@style/AppTheme">

      <activity android:name=".MainActivity">

         <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>

      </activity>

   </application>

</manifest>

How to create a WebView in Android

WebView is a view that display web pages inside your application. You can also specify HTML string and can show it inside your application using WebView. WebView Android makes turns your application to a web application.

In order to add WebView to your application, you have to add <WebView> element to your xml layout file.

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.

Step 2: Create layout res/layout/activity_main.xml.

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"

   android:id = "@+id/parent"

   xmlns:tools = "http://schemas.android.com/tools"

   android:layout_width = "match_parent"

   android:layout_height = "match_parent"

   tools:context = ".MainActivity">

   <WebView

      android:id="@+id/webView"

      android:layout_width="match_parent"

      android:layout_height="match_parent">

   </WebView>

</RlativeLayout>

Step 3: Create class to src/MainActivity.java

public class MainActivity extends AppCompatActivity {

   private WebView webView;

   @Override

   protected void onCreate(Bundle savedInstanceState) {

      super.onCreate(savedInstanceState);

      setContentView(R.layout.activity_main);

      WebView webView = (WebView)findViewById(R.id.webView);

      webView.setWebViewClient(new WebViewClient());

      webView.loadUrl("https://www.google.com");

      WebSettings webSettings = webView.getSettings();

      webSettings.setJavaScriptEnabled(true);

   }

   public void onBackPressed(){

      if (webView.canGoBack()){

         webView.goBack();

    } else {

         super.onBackPressed();

      }

   }

}

Step 4:  Add the following code to androidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="app.com.sample">

   <uses-permission android:name="android.permission.INTERNET"></uses-permission>

   <application

      android:allowBackup="true"

      android:icon="@mipmap/ic_launcher"

      android:label="@string/app_name"

      android:roundIcon="@mipmap/ic_launcher_round"

      android:supportsRtl="true"

      android:theme="@style/AppTheme">

      <activity android:name=".MainActivity">

         <intent-filter>

            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />

         </intent-filter>

      </activity>

   </application>

</manifest>

Sunday, July 4, 2021

How to create BottomNavigationView with Fragment Android Example

Bottom navigation Android bars make it easy for users to explore and switch between top-level views in a single tap. They should be used when an application has three to five top-level destinations.

The bar can disappear on scroll, based on HideBottomViewOnScrollBehavior, when it is placed within a CoordinatorLayout and one of the children within the CoordinatorLayout is scrolled. This behavior is only set if the layout_behavior property is set to HideBottomViewOnScrollBehavior.

In this Example Android you will learn, how to add a bottom navigation to your activity and use it to switch between different fragments. We will fill our BottomNavigationView with 3 menu items and then check which item was selected with the OnNavigationItemSelectedListener interface and a switch statement. We will then create the appropriate fragment and display it in a FrameLayout with help of the getSupportFragmentManager, beginTransaction and replace methods.

Step 1. Create layout bottom_navigation.xml

<?xml version="1.0" encoding="utf-8"?>

<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item

        android:id="@+id/nav_home"

        android:icon="@drawable/ic_home_black_24dp"

        android:title="Home" />

    <item

        android:id="@+id/nav_favorites"

        android:icon="@drawable/ic_favorite_black_24dp"

        android:title="Favorites" />

    <item

        android:id="@+id/nav_search"

        android:icon="@drawable/ic_search_black_24dp"

        android:title="Search" />

</menu>

Step2. Create layout activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.codinginflow.bottomnavigationviewexample.MainActivity">
    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/bottom_navigation"/>
    <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:menu="@menu/bottom_navigation"
        android:background="?android:attr/windowBackground"/>
</RelativeLayout>

Step 3. Create layout fragment_home.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_red_light">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Home Fragment"
        android:textSize="30sp"
        android:layout_centerInParent="true"/>
</RelativeLayout>

Step 4. Create class HomeFragment.java

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class HomeFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container
        @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_homecontainerfalse);
    }
}

Step 5. Create layout fragment_favoties.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_blue_light">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Favorites Fragment"
        android:textSize="30sp"
        android:layout_centerInParent="true"/>

</RelativeLayout>

Step 6. Create class FavoritesFragment.java

public class FavoritesFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater
        @Nullable ViewGroup container
        @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_favoritescontainerfalse);
    }
}

Step 7. Create layout fragment_search.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/holo_green_light">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Search Fragment"
        android:textSize="30sp"
        android:layout_centerInParent="true"/>

</RelativeLayout>

Step 8. Create class SearchFragment.java

public class SearchFragment extends Fragment {
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater,
         @Nullable ViewGroup container
         @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_searchcontainerfalse);
    }
}

Step 9. Create class MainActivity.java

public class MainActivity extends AppCompatActivity {

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        BottomNavigationView bottomNav = findViewById(R.id.bottom_navigation);

        bottomNav.setOnNavigationItemSelectedListener(navListener);

        //I added this if statement to keep the selected fragment when rotating the device

        if (savedInstanceState == null) {

            getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,

                    new HomeFragment()).commit();

        }

    }

    private BottomNavigationView.OnNavigationItemSelectedListener navListener =

            new BottomNavigationView.OnNavigationItemSelectedListener() {

                @Override

                public boolean onNavigationItemSelected(@NonNull MenuItem item) {

                    Fragment selectedFragment = null;

                    switch (item.getItemId()) {

                        case R.id.nav_home:

                            selectedFragment = new HomeFragment();

                            break;

                        case R.id.nav_favorites:

                            selectedFragment = new FavoritesFragment();

                            break;

                        case R.id.nav_search:

                            selectedFragment = new SearchFragment();

                            break;

                    }

                    getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,

                            selectedFragment).commit();

                    return true;

                }

            };

}

How to Fillter item in Recyclerview Android example

RecyclerView makes it easy to efficiently display large sets of data. You supply the data and define how each item looks, and the RecyclerView library dynamically creates the elements when they're needed.

As the name implies, RecyclerView recycles those individual elements. When an item scrolls off the screen, RecyclerView doesn't destroy its view. Instead, RecyclerView reuses the view for new items that have scrolled onscreen. This reuse vastly improves performance, improving your app's responsiveness and reducing power consumption.

In this example we will implement a search functionality for our RecyclerView so we can filter it’s items by their text. For this we will use an EditText, the setTextChangedListener method, a TextWatcher and the afterTextChanged method.

How to Step Fillter item in recyclerview android
Step1. Create example_item.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView 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="wrap_content"
    android:layout_marginBottom="4dp"
    app:cardCornerRadius="4dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="4dp">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:padding="2dp" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentTop="true"
            android:layout_toEndOf="@+id/imageView"
            android:text="Line 1"
            android:textColor="@android:color/black"
            android:textSize="20sp"
            android:textStyle="bold" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textView"
            android:layout_marginStart="8dp"
            android:layout_toEndOf="@+id/imageView"
            android:text="Line 2"
            android:textSize="15sp" />

    </RelativeLayout>

</android.support.v7.widget.CardView>
Step 2. Create model class ExampleItem.java
public class ExampleItem {
    private int mImageResource;
    private String mText1;
    private String mText2;
    public ExampleItem(int imageResource, String text1, String text2) {
        mImageResource = imageResource;
        mText1 = text1;
        mText2 = text2;
    }
    public int getImageResource() {
        return mImageResource;
    }
    public String getText1() {
        return mText1;
    }
    public String getText2() {
        return mText2;
    }
}

Step 3. Create adapter class ExampleAdapter .java
public class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ExampleViewHolder> {
    private ArrayList<ExampleItem> mExampleList;
    public static class ExampleViewHolder extends RecyclerView.ViewHolder {
        public ImageView mImageView;
        public TextView mTextView1;
        public TextView mTextView2;
        public ExampleViewHolder(View itemView) {
            super(itemView);
            mImageView = itemView.findViewById(R.id.imageView);
            mTextView1 = itemView.findViewById(R.id.textView);
            mTextView2 = itemView.findViewById(R.id.textView2);
        }
    }
    public ExampleAdapter(ArrayList<ExampleItem> exampleList) {
        mExampleList = exampleList;
    }
    @Override
    public ExampleViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.example_item, 
                parent, false);
        ExampleViewHolder evh = new ExampleViewHolder(v);
        return evh;
    }
    @Override
    public void onBindViewHolder(ExampleViewHolder holder, int position) {
        ExampleItem currentItem = mExampleList.get(position);
        holder.mImageView.setImageResource(currentItem.getImageResource());
        holder.mTextView1.setText(currentItem.getText1());
        holder.mTextView2.setText(currentItem.getText2());
    }
    @Override
    public int getItemCount() {
        return mExampleList.size();
    }
    public void filterList(ArrayList<ExampleItem> filteredList) {
        mExampleList = filteredList;
        notifyDataSetChanged();
    }
}

Step 4. Create layout  activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.codinginflow.searchfunctionalityexample.MainActivity">

    <EditText
        android:id="@+id/edittext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="16dp"/>

    <android.support.v7.widget.RecyclerView
        android:id="@+id/recyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/darker_gray"
        android:padding="4dp"
        android:scrollbars="vertical" />

</LinearLayout>

Step 5. Create class  MainActivity.java
public class MainActivity extends AppCompatActivity {
    private ArrayList<ExampleItem> mExampleList;
    private RecyclerView mRecyclerView;
    private ExampleAdapter mAdapter;
    private RecyclerView.LayoutManager mLayoutManager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        createExampleList();
        buildRecyclerView();
        EditText editText = findViewById(R.id.edittext);
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            }
            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {
            }
            @Override
            public void afterTextChanged(Editable s) {
                filter(s.toString());
            }
        });
    }
    private void filter(String text) {
        ArrayList<ExampleItem> filteredList = new ArrayList<>();
        for (ExampleItem item : mExampleList) {
            if (item.getText1().toLowerCase().contains(text.toLowerCase())) {
                filteredList.add(item);
            }
        }
        mAdapter.filterList(filteredList);
    }
    private void createExampleList() {
        mExampleList = new ArrayList<>();
        mExampleList.add(new ExampleItem(R.drawable.ic_android, "One", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_audio, "Two", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_sun, "Three", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_android, "Four", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_audio, "Five", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_sun, "Six", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_android, "Seven", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_audio, "Eight", "Line 2"));
        mExampleList.add(new ExampleItem(R.drawable.ic_sun, "Nine", "Line 2"));
    }
    private void buildRecyclerView() {
        mRecyclerView = findViewById(R.id.recyclerView);
        mRecyclerView.setHasFixedSize(true);
        mLayoutManager = new LinearLayoutManager(this);
        mAdapter = new ExampleAdapter(mExampleList);
        mRecyclerView.setLayoutManager(mLayoutManager);
        mRecyclerView.setAdapter(mAdapter);
    }
}