Android – "ERROR: Unknown command ‘crunch’"

|

Problem: How do I solve “ERROR: Unknown command ‘crunch'”? Solution: After updating to ADT r14, go to Window -> SDK Manager (in Eclipse) Check on ‘repository’, uncheck “installed” Wait for packages to load, then select all support packages, accept all and install them Restart Eclipse Run your apps on new ADT...

Android – Interview Questions/Answer Part – 1

|

Que 1: Describe the APK format.  Ans: Android application package file (APK) is the file format used to distribute and install application software and middleware onto the Google Android operating system. (Same as .exe in windows) Each Android application is compiled and packaged in a single file that includes all...

Android – findViewById() in a loop

|

Problem: How do we iterate through all the views(taken in XML layout) programatically? Description: I am sure you don’t get the problem exactly. So let me give more idea for the better understanding of this problem. Consider, i have declared 10 button with ‘id’ like button1, button2, button3, button4, button5, button6...

Android – check Internet connection

|

Problem: How To check whether the device has network connection or not? Solution: Update: This will work for both Emulator & Device. I got this helpful information from this SO answer. Note the use of isAvailable – without this isConnected can return TRUE even when WIFI is disabled....

Android – Get Current Date and Time

|

Problem: How to get current current date and time in Android? Description: For fetching current date and time, we use Calendar class to get the current instance of system clock of phone: Once we are having object of Calendar, we can retrieve date/time value in any desirable format, say for...

Android – create EditText programatically

|

Problem: How to create EditText programatically? Solution: [sourecode language=”java”] EditText ed = new EditText(this); // Type of input that you want from user to input i.e. number, text ed.setInputType(InputType.TYPE_CLASS_TEXT); // set the width/height of edittext ed.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); // text color ed.setTextColor(Color.MAGENTA); // text to view initially inside the edit...

Android – Bullets in ListView

|

Problem: How to show bullets in ListView/TextView in Android? Description:  There is no easy way to show indentation in ListView/TextView, so here i made a trick and define a drawable to display Bullet at left side of each item of the ListView. And i have defined a custom listview row...