Skip to main content

Posts

Showing posts from 2018

Shake a view(edit text) on incorrect input at OTP,passwords,etc (Android)

Hello devs! This is another short tutorial to show how to shake an Edit text view if the input is incorrect. Note : The tutorial assumes that you have the basic knowledge about android development. It involves the following steps : 1. Create the Edit text and cast it inside the onCreate. EditText edittext=findViewById(R.id.edit_text); Recommended : https://github.com/GoodieBag/Pinview Optional - Put the edit text inside a dialog to take an input from the dialog. 2. Write an animation XML. Here is an example: ( shake.xml ) Courtesy : https://gist.github.com/simon-heinen/9795036 <? xml version = " 1.0 " encoding = " utf-8 " ?> < set xmlns : android = " http://schemas.android.com/apk/res/android " > < rotate android : duration = " 70 " android : fromDegrees = " -5 " androi

Create drop-down menu with image icons in Android

Hello devs! In this tutorial, we will be creating a drop-down menu on clicking a button in Android studio. Here is an image of how our menu is going to look: On clicking the hamburger icon, a vertical menu will appear with image icons of your choice. Above image is just to get an idea of what we are going to develop. Let's get started. Step 1: Open the layout file where you want the menu. Add the hamburger icon on an image button. <ImageButton android :layout_width= "50dp" android :layout_height= "50dp" android :src= "@drawable/ham" android :id= "@+id/ham" android :background= "#00000000" />  Note : #00000000 specifies 'transparent' background. Step 2: Add a vertical linear layout for the menu. Inside that, add nested linear layouts for horizontal rows. <LinearLayout android :layout_width= "wrap_content" android :layout_height= "wrap_content&quo

Open the last opened activity in Android and save values. (Android Studio)

Hello devs! This post is going to tell you a way to open the last opened activity in Android. There are cases where we keep a login for the app and we need to use that login every time we open the app. However, you see in good apps, you don't need to login each time unless you logout. Following are the ways to achieve this: 1. Firebase Auth - this is the simplest way. However, if you don't want to use Firebase or have your own API, check out the next method. 2. SharedPreferences - Following is the way to make use of that: 1. In every activity you wish to open, add the following code. @Override protected void onPause() { super.onPause(); SharedPreferences prefs = getSharedPreferences("X", MODE_PRIVATE ); SharedPreferences.Editor editor = prefs.edit(); editor.putString( "lastActivity" , getClass().getName()); editor.commit(); } This could be your MainActivity and your LoginActivity. 2. Next, create a class called a

Fix 'Script/ content not visible/working' issues.

While using a website or while working on web development projects, a common issue we face is that the scripts do not work. Or the content such as 'xsl' type files are not displayed. This happens a lot with Google Chrome. You may spend hours trying to figure out what's wrong. Here's what you need to do (Common debugging technique for web development): 1. Right click -> Inspect element. 2. Go to Console section. 3. If you find error messages like 'Unable to load', this solution might help. Change your browser. Google Chrome blocks scripts for security purpose. Fix is simple. Just download Firefox and you are good. Firefox also provides inspect element features like Chrome. Hope this helps!

Add 'Night mode' using AngularJS

Night mode is said to decrease the light intensity and cause less stress to viewer's eyes. Adding night mode to your websites and blogs would be beneficial to your viewers who prefer reading at night. Although most of the users generally have a browser add-on, adding this small feature won't do you any harm. Also, if you are a web developer, you can integrate this with your project. Night mode is usually turning a white page black and black font white. Other changes can also be added easily in AngularJS. This post assumes that you have basic knowledge about AngularJS. Follow the steps: 1. Import AngularJS script into your project. <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> 2 . Add ng-app and ng-controller to your <HTML> tag. <html ng-app="" ng-controller="myCtrl"> 3 . Add ng-style to your body or any particular div where you want to see the effect. <div

About firebase serve

Here is the shortest guide on firebase serve: 1)Firebase serve is used to start your server and host the project on your localhost. command: firebase serve (in your firebase project folder command line) 2)It also provides logs of access. 3) Use -p followed by post number to specify the port. Default is 5000 . 4) Use -o followed by host to specify the host. Default is localhost . 5) Use --only and --except to serve only a specific or serve all except specific file. 6)Following command will stop a process on the terminal: Ctrl + c Hope it helps :)

Fix ' VMware not connecting to internet' issue.

VMware may stop connecting to the internet due to various reasons. One most common issue is that the NAT service  stopped working. Windows might automatically stop this service due to various reasons.(Usually during Windows update). The easiest way to fix this is start the service manully in task manager. Steps: 1. Open task manager. 2. Open Services tab. 3. Locate VMware services. Right click and start if not running. Well, I hope in the later versions, VMware checks if the service is running or not automatically and solves the issue :)