Found 2041 Articles for Mobile Development

How to add footer in Android ListView?

Azhar
Updated on 03-Jul-2020 08:30:11

767 Views

This example demonstrates how do I add footer in 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 – Create a layout file.xml and name it as listView_footer.xml and add the following code −         Step 4 − Add the following code to src/MainActivity.javaimport java.util.ArrayList; import java.util.Arrays; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.ViewGroup; import android.widget.ArrayAdapter; import ... Read More

Dynamically add elements in ListView in android?

Azhar
Updated on 03-Jul-2020 08:31:00

3K+ Views

This example demonstrates how do I dynamically add elements in 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 java.util.ArrayList; import java.util.Arrays; import java.util.List; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; public class MainActivity extends Activity {    ListView listview;    Button addButton; ... Read More

How to create clickable links in a textView on Android?

Azhar
Updated on 03-Jul-2020 08:32:53

3K+ Views

This example demonstrates how do I create clickable links in a textView 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 – Open res/values/strings.xml and add the following code −    Sample    Tap here to open Link Step 4 − Add the following code to src/MainActivity.javapackage app.com.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.method.LinkMovementMethod; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView textView;   ... Read More

How to turn on Flash light programmatically in android?

Azhar
Updated on 03-Jul-2020 08:25:45

3K+ Views

This example demonstrates how do I turn on Flash light programatically 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 android.content.Context; import android.content.DialogInterface; import android.content.pm.PackageManager; import android.hardware.camera2.CameraAccessException; import android.hardware.camera2.CameraManager; import android.os.Bundle; import android.support.v7.app.AlertDialog; import android.support.v7.app.AppCompatActivity; import android.widget.CompoundButton; import android.widget.ToggleButton; public class MainActivity extends AppCompatActivity {    private CameraManager mCameraManager;    private String mCameraId;    private ToggleButton toggleButton;   ... Read More

How can I send emails using gmail from my Android application?

Azhar
Updated on 03-Jul-2020 08:27:02

405 Views

This example demonstrates how do I send emails using gmail from my Android application.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 android.content.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.EditText; public class MainActivity extends AppCompatActivity{    EditText editTextMail, editTextSubject, ... Read More

How do I specify different layouts for portrait and landscape orientations in Android?

Azhar
Updated on 30-Nov-2020 13:06:37

2K+ Views

This example demonstrates how do I specify different layouts for portrait and landscape orientations in androidStep 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 – Create a layout file by right-clicking on the resources, name the file, from the ‘Available qualifiers, select Orientation.Click >> option.Select Landscape from UI mode.Add the following code in the res/layout/land/activity_main.xml         Step 4 − Add the following code to ... Read More

How to request Location permission at run time in Android?

Azhar
Updated on 01-Jul-2020 07:31:56

5K+ Views

This example demonstrates how do I request Location permission 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 android.Manifest; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; 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);       if ... Read More

How to pick up and hung up calls in android?

Azhar
Updated on 07-Aug-2019 11:45:57

294 Views

This example demonstrates how do I pick up and hung up calls 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 android.Manifest; import android.content.pm.PackageManager; import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.support.v7.app.AppCompatActivity; 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);   ... Read More

How to use SearchView in Toolbar Android?

Azhar
Updated on 01-Jul-2020 06:00:38

2K+ Views

This example demonstrates how do I use searchView in Toolbar 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 android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.SearchView; import android.support.v7.widget.Toolbar; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    Toolbar toolbar;    ArrayAdapter adapter;    ListView listView;    TextView emptyView; ... Read More

How to play audio file from the assets directory in Android?

Azhar
Updated on 01-Jul-2020 06:03:41

2K+ Views

This example demonstrates how do I play audio file from the assets directory 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 − Create a asset folder, Right click on the project → New → Folder → Asset Folder.Copy and paste the audio file into the assets folder.Step 4 − Add the following code to src/MainActivity.javaimport android.content.res.AssetFileDescriptor; import android.media.MediaPlayer; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.Toast; ... Read More

Advertisements