Change Position of Dialog on Screen in Android

Azhar
Updated on 03-Jul-2020 12:49:28

2K+ Views

This example demonstrates how do I change the position of the dialog on Screen 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.app.AlertDialog; import android.content.DialogInterface; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.Gravity; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       AlertDialog.Builder builder = new AlertDialog.Builder(this);     ... Read More

Create Smooth Image Rotation in Android

Azhar
Updated on 03-Jul-2020 12:48:55

285 Views

This example demonstrates how do I create a smooth image rotation 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 new folder named “anim” in the res. Right click on anim folder and create an animation resource file (rotate.xml) and add the following code −     Step 3 − Add the following code to src/MainActivity.javaimport android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; ... Read More

Execute Async Task Repeatedly After Fixed Time Intervals in Android

Azhar
Updated on 03-Jul-2020 12:48:21

767 Views

This example demonstrates how do I execute AsyncTask repeatedly after fixed time intervals 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.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       RunTask();    }   ... Read More

Display JRadioButtonMenuItem in Java

raja
Updated on 03-Jul-2020 12:47:44

1K+ Views

A JRadioButtonMenuItem is a subclass of the JMenuItem class in Java. A JRadioButtonMenuItem is a menu item that is part of a group of menu items in which only one item in the group can be selected and the selected item displays its selected state. We can add multiple radio button menu items to a ButtonGroup object to form a button group. If one radio button menu item in a button group is selected, all other radio button menu items will be unselected.Syntaxpublic class JRadioButtonMenuItem extends JMenuItem implements AccessibleExampleimport javax.swing.*; import java.awt.*; public class JRadioButtonMenuItemTest extends JFrame {    private JMenuBar mb;   ... Read More

Overlay Two Images in Android to Set an ImageView

Azhar
Updated on 03-Jul-2020 12:47:07

3K+ Views

This example demonstrates how do I overlay two images In Android to set an ImageView.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 and paste two images which you want to overlay(Merge) in the res/drawable Then Create a drawable resource file (layer.xml) and add the following code,         Step 3 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; ... Read More

Create Dialog Box Without a Title in Android

Azhar
Updated on 03-Jul-2020 12:45:02

255 Views

This example demonstrates how to create a Dialog Box without a title 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.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class Dialog extends AppCompatActivity {    Button ... Read More

Copy Text Programmatically in Android App using Ctrl+C

Azhar
Updated on 03-Jul-2020 12:44:28

1K+ Views

This example demonstrates how do I copy text programmatically (Ctrl+C) in my android app.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.ClipData; import android.content.ClipboardManager; import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.EditText; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {    EditText editText;    TextView textView;    ClipboardManager clipboardManager;    @Override   ... Read More

Change Action Bar Size in Android

Azhar
Updated on 03-Jul-2020 12:42:48

3K+ Views

This example demonstrates how to change action bar size 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/values/styles.xml                     @color/colorAccent       @color/colorPrimary       @color/colorAccent       36dip     Step 3  − Add the following code to res/layout/activity_main.xml.     Step 4  − Add the following code to src/MainActivity.javapackage com.example.sample; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends ... Read More

Justify Text in TextView on Android

Azhar
Updated on 03-Jul-2020 12:42:00

7K+ Views

This example demonstrates how to Justify Text in 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  − Add the following code to src/MainActivity.javapackage com.example.sample; 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);    } }Step 3  − Add the following code to Manifests/AndroidManifest.xml       ... Read More

Create Android Hello World App

Azhar
Updated on 03-Jul-2020 12:41:23

420 Views

This example demonstrates how to create Android Hello World App.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.example.sample; 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);    } }Step 4  − Add the following code to Manifests/AndroidManifest.xml           ... Read More

Advertisements