Found 1631 Articles for Android

How to create Android Hello World App?

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

314 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

How to Justify Text in TextView on Android?

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

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

How to change action bar size in Android?

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

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

How to read value from string.xml in Android?

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

1K+ Views

This example demonstrates how to read value from string.xml 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/strings.xml    Sample    Test string 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 AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } }Step ... Read More

How do I declare global variables on Android?

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

1K+ Views

This example demonstrates how to declare global variables 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.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends AppCompatActivity {    TextView tvEvent;    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       ... Read More

How do I create a transparent Activity in an Android App?

Azhar
Updated on 03-Jul-2020 12:37:06

2K+ Views

This example demonstrates how to create a transparent Activity 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.               #33000000       true       @android:color/transparent       @null       true       @android:style/Animation     Step 3  − Add the following code to res/layout/activity_main.xml.         Step 4  − Add the following code to src/MainActivity.javapackage com.example.transparentactivity; import android.support.v7.app.AppCompatActivity; ... Read More

How do I change current theme at runtime in my android app?

Azhar
Updated on 03-Jul-2020 11:49:36

981 Views

This example demonstrates how do I change current theme at runtime 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 android.support.v7.app.AppCompatActivity; import android.os.Bundle; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setTheme(android.R.style.Theme_Black);       setContentView(R.layout.activity_main);    } }Step 4 − Add the following code to androidManifest.xml ... Read More

How to switch between different activities in android?

Azhar
Updated on 03-Jul-2020 10:14:05

4K+ Views

This example demonstrates how do I switch between different activities 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.Intent; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; public class MainActivity extends AppCompatActivity {    Button button;    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);       button = findViewById(R.id.btnOpenAct2);       ... Read More

How to create TextToSpeech in an android app?

Azhar
Updated on 03-Jul-2020 10:14:44

109 Views

This example demonstrates how do I create TextToSpeech in an 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 android.speech.tts.TextToSpeech; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.SeekBar; import java.util.Locale; public class MainActivity extends AppCompatActivity {    private TextToSpeech textToSpeech;    private EditText editText;    private ... Read More

How to play YouTube video in my Android Application?

Azhar
Updated on 03-Jul-2020 10:15:17

2K+ Views

This example demonstrates how do I play Youtube video 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 following the dependancies in the build.gradle (Module:app)implementation 'com.android.support:recyclerview-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0'Step 3 − Add the following code to res/layout/activity_main.xml.         Step 4 – Create a layout resource file (Video_view.xml) and add the following code − Step 5 – Create a java class youTubeVideos.java and the following code −public class youTubeVideos {    String videoUrl;    public youTubeVideos() ... Read More

Advertisements