Azhar

Azhar

451 Articles Published

Articles by Azhar

Page 37 of 46

How to filter a RecyclerView with a SearchView on Android?

Azhar
Azhar
Updated on 15-Nov-2019 6K+ Views

This example demonstrates how to filter a RecyclerView with a SearchView on Android.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import android.os.Bundle; import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.inputmethod.EditorInfo; import android.widget.SearchView; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity {    private ExampleAdapter adapter;    private List exampleList;    @Override    protected void ...

Read More

How do I change the background color of the ActionBar of an ActionBarActivity?

Azhar
Azhar
Updated on 15-Nov-2019 1K+ Views

This example demonstrates how to change the background color of the ActionBar of an ActionBarActivityStep 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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to Manifests/AndroidManifest.xml ...

Read More

How to change color and font of Android ListView?

Azhar
Azhar
Updated on 15-Nov-2019 2K+ Views

This example demonstrates how to change the color and font of Android ListView.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaStep 4 − Add the following code to Manifests/AndroidManifest.xml                                                             ...

Read More

How ListView's recycling mechanism works on Android?

Azhar
Azhar
Updated on 15-Nov-2019 189 Views

This example demonstrates how ListView's recycling mechanism works on Android.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to res/layout/card_row.xml.     Step 4 − Add the following code to src/MainActivity.javapackage com.app.sample; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity {    private ArrayList cities;    @Override ...

Read More

How to answer in incoming call programmatically in Android?

Azhar
Azhar
Updated on 15-Nov-2019 3K+ Views

This example demonstrates how to answer in incoming call programmatically in Android.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    public void acceptCall() {       ...

Read More

How to create custom notification layouts and text colors in Android?

Azhar
Azhar
Updated on 15-Nov-2019 2K+ Views

This example demonstrates how to create custom notification layouts and text colors in Android .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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javapackage com.app.sample; import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.NotificationCompat; import android.os.Bundle; import android.os.Bundle; import android.app.Activity; import android.app.NotificationManager; import android.app.PendingIntent; import android.content.Intent; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.RemoteViews; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) ...

Read More

How to make an alert dialog fill 50% of screen size on Android device?

Azhar
Azhar
Updated on 15-Nov-2019 2K+ Views

This example demonstrates how to make an alert dialog to fill 50% of screen size on an Android device.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 − Add the following code to res/layout/activity_main.xml.    

Read More

How to detect shake event in Android app?

Azhar
Azhar
Updated on 15-Nov-2019 2K+ Views

This example demonstrates how to do I in android.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; import android.hardware.SensorEventListener; import android.hardware.SensorManager; import android.os.Bundle; import android.widget.Toast; import java.util.Objects; public class MainActivity extends AppCompatActivity {    private SensorManager mSensorManager;    private float mAccel;    private float mAccelCurrent;    private float mAccelLast;    @Override    protected void onCreate(Bundle savedInstanceState) ...

Read More

How to hide status bar in Android?

Azhar
Azhar
Updated on 15-Nov-2019 2K+ Views

This example demonstrates how to do I in android.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       requestWindowFeature(Window.FEATURE_NO_TITLE);       getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following ...

Read More

How to permanently hide Navigation Bar in an Android Activity?

Azhar
Azhar
Updated on 15-Nov-2019 3K+ Views

This example demonstrates how do I permanently hide Navigation Bar in an Android Activity in android.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 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.annotation.SuppressLint; import android.os.Build; import android.os.Bundle; import android.view.View; public class MainActivity extends AppCompatActivity {    private int currentApiVersion;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       currentApiVersion ...

Read More
Showing 361–370 of 451 articles
« Prev 1 35 36 37 38 39 46 Next »
Advertisements