How to create transparent statusbar and ActionBar in Android?

Azhar
Updated on 15-Nov-2019 11:00:11

2K+ Views

This example demonstrates how to create a transparent statusbar and ActionBar 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.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 res/values/styles.xml         ... Read More

How to filter a RecyclerView with a SearchView on Android?

Azhar
Updated on 15-Nov-2019 10:55:38

5K+ 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
Updated on 15-Nov-2019 10:43:40

797 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
Updated on 15-Nov-2019 10:34:56

1K+ 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
Updated on 15-Nov-2019 10:28:16

67 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
Updated on 15-Nov-2019 10:20:59

2K+ 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
Updated on 15-Nov-2019 10:15:00

1K+ 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
Updated on 15-Nov-2019 10:01:48

1K+ 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.    

How to detect shake event in Android app?

Azhar
Updated on 15-Nov-2019 09:56:19

1K+ 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 use search functionality in custom list view in Android?

Azhar
Updated on 15-Nov-2019 09:51:56

1K+ Views

This example demonstrates how do I use the search functionality in custom listview 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.text.Editable; import android.text.TextWatcher; import android.widget.ArrayAdapter; import android.widget.EditText; import android.widget.ListView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity {    ListView listView;    ArrayList months = new ArrayList();    ArrayAdapter arrayAdapter;    EditText etSearch;    @Override ... Read More

Advertisements