How to Stop EditText from gaining focus at Activity startup ?

You may noticed that, When an activity with EditText field starts, the EditText immediately has input focus and shows the keyboard. We can fix it by adding two attributes to the parent layout.

android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true"

And now when activity starts this layout getting default focus. No more EditText focus problem.



Read more

How To Set C# ComboBox Selected Item or Index By Text ?

In some cases we may need to set the ComboBox selected index by a specific text included in the ComboBox items. In C# we can achieve this without adding any extra line of code. here it is...

myComboBox.SelectedIndex = myComboBox.Items.IndexOf("mysampletext");


Read more

How To Make C# ComboBox Non Editable ?



By default C# ComboBox text part is editable. If we want to change it to non editable we can achieve it by simply setting the ComboBox DropDownStyle property to DropDownList. Here is the Code ..

MyComboBox.DropDownStyle = ComboBoxStyle.DropDownList;



Read more

How To Use Custom and SDK Fonts in Android ?

android using custom and sdk font
When we design a layout the default font may not fit well for all the layouts and widgets. In Android SDK the number of fonts included is limited to 3, which are Droid sans , Droid Sans Mono and Droid Serif. Switching between these fonts are very easy as you can change to any of these Droid fonts using both XML and Java. But, to use a custom font in Android you have to set via java code.


In this post i am included the simple steps to change font in android. The methods included to use default and custom fonts.

How To Use Available SDK fonts in Android?


Method 1 [ Using XML ]

1. Use android:typeface property in your view ie. Button,EditText,TextView etc. Where you can select any of the system font available in the SDK ie. Droid sans , Droid Sans Mono and Droid Serif.

<textview xmlns:android="http://schemas.android.com/apk/res/android"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:textSize="20sp"
 android:typeface="serif"
/ >

Method 2 [ Using Java ]

Call setTypeFace() method on the Views object eg TextView , EditText , Button, etc.

TextView textView = (TextView) findViewById(R.id.TextViewId);
textView.setTypeface(Typeface.SERIF);

How To Use Custom fonts in Android?


Method [ Using Java ]
This also use the setTypeFace() method but need some additional steps.

1. Create a folder named fonts in assets folder and copy all fonts it to it. ( You can use any folder instead of fonts )



2. In Activity Java file Create TypeFace object and load font face from asset.

Typeface tf = Typeface.createFromAsset(getAssets(), "PATH_TO_FONT");

3. Finally set the created TypeFace to the view.

textView.setTypeface(typeface_object);

Here is the example code:
TextView textView = (TextView) findViewById(R.id.TextViewId);
// Loading font from assets
Typeface tfIron=Typeface.createFromAsset(getAssets(), "fonts/Iron.ttf");
// applying to the view
textView.setTypeface(tfIron);

That's it...


Read more

Jquery Basic Form Validation Guide ?



Read more