Mobile Development Articles - Page 68 of 156

How to lock screen orientation on all android devices programmatically?

Azhar
Updated on 01-Jul-2020 07:48:49

2K+ Views

This example demonstrates how do I lock screen orientation on all android devices programmatically.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.pm.ActivityInfo; import android.content.res.Configuration; import android.support.v7.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);       int currentOrientation = getResources().getConfiguration().orientation;     ... Read More

How do I create a TableView with rounded corners in iOS?

Mohtashim M
Updated on 07-Aug-2019 14:05:02

2K+ Views

Table View is one of the most important and fundamental part of iOS application, Every iOS developer should be familiar with it.Almost every application you see in App store use table view.Table views on iOS display a single column of vertically scrolling content, divided into rows. Each row in the table contains one piece of your app’s content. For example, the Contacts app displays the name of each contact in a separate row, and the main page of the Settings app displays the available groups of settingsYou can read more about table view here,  https://developer.apple.com/documentation/uikit/uitableviewIn this post we will see ... Read More

How to set margin of ImageView using code in Android?

Azhar
Updated on 01-Jul-2020 07:49:26

1K+ Views

This example demonstrates how do I set margin of ImageView using code 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 – Copy an image file and paste in the res/drawableStep 4 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ImageView; import android.widget.RelativeLayout; public class MainActivity extends AppCompatActivity {    ImageView imageView;    @Override    protected void onCreate(Bundle savedInstanceState) {   ... Read More

How to detect user pressing HOME key in iOS?

Mohtashim M
Updated on 07-Aug-2019 13:59:26

385 Views

It is very important to know when user is pressing home key as it puts the application to background, here we will be seeing how to identify or get a call when user presses home key.In you AppDelegate.swift, there are delegates methods.Open your AppDelegate.swift and in applicationWillResignActive(_ application: UIApplication) and applicationDidEnterBackground(_ application: UIApplication), write print statement and put a breakpoint as shown.Run the application, once the app is launch tap the home button, applicationWillResignActive will be called and then applicationDidEnterBackground.

How can I create custom button in Android using XML Styles?

Azhar
Updated on 01-Jul-2020 07:38:38

3K+ Views

This example demonstrates how do I create custom button in Android using XML Styles.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 – Right Click on res/drawable, Select new → Drawable resource file and add the following code in custom_dialog.xml         Step 4 – Right Click on res/drawable, Select new → Drawable resource file and add the following ... Read More

How to get a working vertical seekBar in Android?

Azhar
Updated on 01-Jul-2020 07:39:32

1K+ Views

This example demonstrates how do I get a working vertical seekBar 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.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.SeekBar; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    SeekBar seekBar;    TextView textView;    int min = 0, max = 100, current = 50;    @Override    protected ... Read More

How to add footer in Android ListView?

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

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

4K+ 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

4K+ 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

Advertisements