How to add calendar events in Android App?

Azhar
Updated on 22-Nov-2019 09:08:12

2K+ Views

This example demonstrates how do I add calendar events 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.Intent; import android.os.Bundle; import android.view.View; import java.util.Calendar; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    }    public void AddCalendarEvent(View view) {       ... Read More

How to call an activity method from a fragment in Android App?

Azhar
Updated on 22-Nov-2019 09:07:12

5K+ Views

This example demonstrates how do I call an activity method from a fragment 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 androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; 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);       FragmentManager fragmentManager = getSupportFragmentManager();     ... Read More

How to iterate a JSON Array in Android?

Azhar
Updated on 22-Nov-2019 09:06:26

852 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

Binary representation of next number in C++

sudhir sharma
Updated on 22-Nov-2019 09:05:48

375 Views

In this problem, we are given the binary representation of a number and we have to find the binary representation of the next number i.e. the number that is resulted after adding one to the given number.Binary representation of a number is changing the base of the number to base 2 and representing the number using only 0 or 1.For example, Binary representation of 14 is 1110.So, here we would be given a number, let's say n in binary form. And we have to find the binary representation of n+1.To solve this problem, we need to know the basics of ... Read More

How should I validate an e-mail address in Android?

Azhar
Updated on 22-Nov-2019 09:05:43

112 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

How to use RecyclerView inside NestedScrollView in Android?

Azhar
Updated on 22-Nov-2019 09:04:50

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

How to properly highlight selected item on Android RecyclerView?

Azhar
Updated on 22-Nov-2019 09:04:09

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

How to use the recyclerview with a database in Android?

Azhar
Updated on 22-Nov-2019 09:03:27

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

Binary Insertion Sort in C++

sudhir sharma
Updated on 22-Nov-2019 09:02:40

3K+ Views

Binary Insertion sort is a special type up of Insertion sort which uses binary search algorithm to find out the correct position of the inserted element in the array.Insertion sort is sorting technique that works by finding the correct position of the element in the array and then inserting it into its correct position.Binary search is searching technique that works by finding the middle of the array for finding the element.As the complexity of binary search is of logarithmic order, the searching algorithm’s time complexity will also decrease to of logarithmic order.Implementation of binary Insertion sort. this program is a ... Read More

How to detect device is Android phone or Android tablet?

Azhar
Updated on 22-Nov-2019 08:48:25

2K+ Views

This example demonstrates how do I detect the device is an Android phone or Android tablet.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.os.Bundle; import android.telephony.TelephonyManager; import android.widget.Toast; import java.util.Objects; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       TelephonyManager manager = ... Read More

Advertisements