How to display animated gif images in Android?

Azhar
Updated on 26-Nov-2019 07:33:23

3K+ Views

This example demonstrates how do I display animated gif images 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 build.gradle: Module: appimplementation 'com.github.bumptech.glide:glide:4.9.0'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.ImageView; import com.bumptech.glide.Glide; public class MainActivity extends AppCompatActivity {    @Override    protected void onCreate(Bundle savedInstanceState) {       super.onCreate(savedInstanceState);       setContentView(R.layout.activity_main);    } ... Read More

How to create a multilevel ListView in an Android app?

Azhar
Updated on 26-Nov-2019 07:30:45

414 Views

This example demonstrates how do I create a multilevel 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 androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.ExpandableListAdapter; import android.widget.ExpandableListView; import android.widget.Toast; import java.util.ArrayList; import java.util.HashMap; import java.util.List; public class MainActivity extends AppCompatActivity {    ExpandableListView expandableListView;    ExpandableListAdapter expandableListAdapter;    ListexpandableListTitle;    HashMap expandableListDetail;    @Override    protected void onCreate(Bundle savedInstanceState) {   ... Read More

How to create animation using XML file in an Android App?

Azhar
Updated on 26-Nov-2019 07:21:17

1K+ Views

This example demonstrates how do I create an animation using XML 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 − Create a new android resource directory (anim) and create these below mentioned anim resource filesMyanim.xml     zoom.xml     blink.xml     Step 4 − Add the following code to src/MainActivity.javaimport androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.view.animation.Animation; import android.view.animation.AnimationUtils; ... Read More

How can I encode a URL in Android?

Azhar
Updated on 26-Nov-2019 07:14:11

892 Views

This example demonstrates how do I can encode a URL 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.graphics.Bitmap; import android.os.Bundle; import android.view.View; import android.webkit.WebView; import android.webkit.WebViewClient; import android.widget.Button; import android.widget.Toast; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; public class MainActivity extends AppCompatActivity {    Button button;    private WebView webView;    String strURL;    private String query;    public ... Read More

How to use Android Picasso Library to download images?

Azhar
Updated on 26-Nov-2019 07:10:11

204 Views

This example demonstrates how do I use the Android Picasso library to download images.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 to the build gradle (Module: app)implementation 'com.squareup.picasso:picasso:2.4.0'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.Button; import android.widget.ImageView; import com.squareup.picasso.Picasso; public class MainActivity extends AppCompatActivity {    ImageView imageView;    Button btnDownload;    @Override    protected void onCreate(Bundle savedInstanceState) ... Read More

How does one use Glide to download an image into a bitmap?

Azhar
Updated on 26-Nov-2019 07:06:23

1K+ Views

This example demonstrates how do I does one Glide to download an image into a bitmap.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new projectAdd the following dependency in build.gradle: Module: appimplementation 'com.github.bumptech.glide:glide:4.9.0'Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.widget.ImageView; import com.bumptech.glide.Glide; import com.bumptech.glide.request.target.CustomTarget; import com.bumptech.glide.request.transition.Transition; public class MainActivity extends AppCompatActivity {    ImageView imageView;    @Override   ... Read More

How to use Location API in Android to track your current location?

Azhar
Updated on 26-Nov-2019 07:02:22

348 Views

This example demonstrates how do I use Location API in android to track your current location.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.google.android.gms:play-services-maps:17.0.0'Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 − Add the following code to src/MainActivity.javaimport androidx.fragment.app.FragmentActivity; import android.os.Bundle; import com.google.android.gms.maps.CameraUpdateFactory; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.OnMapReadyCallback; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {    GoogleMap mMap;    @Override    protected void onCreate(Bundle savedInstanceState) ... Read More

How to use NavigationView in Android?

Azhar
Updated on 26-Nov-2019 06:57:42

2K+ Views

This example demonstrates how do I Use NavigationView 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.os.Bundle; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import android.view.View; import androidx.navigation.NavController; import androidx.navigation.Navigation; import androidx.navigation.ui.AppBarConfiguration; import androidx.navigation.ui.NavigationUI; import com.google.android.material.navigation.NavigationView; import androidx.drawerlayout.widget.DrawerLayout; import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import android.view.Menu; public class MainActivity extends AppCompatActivity {    private AppBarConfiguration mAppBarConfiguration;    @Override    protected void onCreate(Bundle savedInstanceState) { ... Read More

How to implement endless list with RecyclerView in Android?

Azhar
Updated on 26-Nov-2019 06:49:32

249 Views

This example demonstrates how do I implement an endless list with RecyclerView 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 build gradle (Module app) −implementation 'com.android.support:cardview-v7:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0'Step 2 − Add the following code to res/layout/activity_main.xml.     Step 3 − Add the following code to src/MainActivity.javaimport androidx.annotation.NonNull; import androidx.appcompat.app.AppCompatActivity; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.os.Bundle; import android.os.Handler; import java.util.ArrayList; public class MainActivity extends AppCompatActivity {    RecyclerView recyclerView;    RecyclerViewAdapter recyclerViewAdapter;    ArrayListrowsArrayList = new ... Read More

How can I style an Android Switch widget?

Azhar
Updated on 26-Nov-2019 06:41:42

546 Views

This example demonstrates how do I Style an Android Switch Widget 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 drawable resource file (customswitchselector.xml) and add the following code −                                                               ... Read More

Advertisements