- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 2041 Articles for Mobile Development
910 Views
This example demonstrates how do I iterate JSON Array 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.widget.TextView; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; public class MainActivity extends AppCompatActivity { TextView textView; String strJson = "{ \"Employee\" :[{\"ID\":\"01\", \"Name\":\"Sam\", \"Salary\":\"50000\"}, " + "{\"ID\":\"02\", \"Name\":\"Shankar\", \"Salary\":\"60000\"}] }"; @Override protected void onCreate(Bundle ... Read More
141 Views
This example demonstrates how do I validate an email address 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.View; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends AppCompatActivity { EditText editText; String email; String emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\.+[a-z]+"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ... Read More
2K+ Views
This example demonstrates how do I use RecyclerView inside NestedScrollView 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.Add the following dependency in the build.gradle (Module: app)implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:design:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0' implementation 'com.intuit.sdp:sdp-android:1.0.3'Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Create a layout resource file (list_item.xml) and add the following code − ... Read More
2K+ Views
This example demonstrates how do I properly highlight the selected item on android RecyclerView.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Add the following dependency in the build.gradle (Module: app)implementation 'com.android.support:recyclerview-v7:28.0.0'Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Create a layout resource file (list_layout.xml) and add the following code − Step 4 − Create drawable resource files as mentioned below and add the respective codes −background_selector.xml − ... Read More
4K+ Views
This example demonstrates how do I use the recyclerview with a database 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.Add the following dependency in the build.gradle (Module: app)implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0' implementation 'com.android.support:design:28.0.0'Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Create layout resource files as mentioned below add the respective codes −add_contacts.xml − contact_list_layout.xml − ... Read More
307 Views
This example demonstrates how How to display the count of notifications in Android App launcher.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.annotation.SuppressLint; import android.os.Bundle; import android.app.NotificationChannel ; import android.app.NotificationManager ; import android.app.PendingIntent ; import android.content.Intent ; import android.os.Bundle ; import android.view.View ; import static android.app.Notification. BADGE_ICON_SMALL ; public class MainActivity extends AppCompatActivity { static ... Read More
976 Views
This example demonstrates how to implement a custom AlertDialog View 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 res/layout/my_dialog.xml. Step 4 − Add the following code to res/drawable/button_background.xml. ... Read More
2K+ Views
This example demonstrates how to height of the status bar 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; import android.content.res.Resources; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); getStatusBarHeight(); } private int getStatusBarHeight() ... Read More
946 Views
This example demonstrates how to animate RecyclerView items when they appear on the screen .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/anim/down_to_up.xml. Step 4 − Add the following code to res/anim/left_to_right.xml. Step 5 − Add the following code to res/anim/right_to_left.xml. Step 6 − Add the ... Read More
3K+ Views
This example demonstrates how to make the corners of a button round 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/drawable/mybutton.xml. ... Read More