Breaking News
Home / Android / Android Snippets (page 4)

Android Snippets

How to allow multiple line text in EditText view in Android?

The EditText widget by default is single line. In order to allow mutiple lines modify and customize the widget definition in the layout file as below: <EditText    android:singleLine=”false” <!– The Default Value is true, change to false –>    android:lines=”8″ <!– The Height of Widget in terms of total Lines  –>    …

Read More »

How to load an remote image as a Drawable in Android?

Loading an remote image from a online server accessible via a URL as Drawable is very straightforward. // Utililty Method public static Drawable loadImageAsDrawable(String url) {    try {         // open the stream        InputStream is = (InputStream) new URL(url).getContent();         String imageName = “xyz”;        Drawable draw = Drawable.createFromStream(is, imageName );        …

Read More »

How do you convert CharSequence to String in Android?

Answer The CharacterSequence is an interface as defined below // Compiled from (version 1.5 : 49.0, no super bit)public abstract interface java.lang.CharSequence {    // Method descriptor #4 ()I  public abstract int length();    // Method descriptor #6 (I)C  public abstract char charAt(int arg0);    // Method descriptor #8 …

Read More »