Posts

Using Button Selectors in Android

If you do somethings in Buttons like background changing, stroke color means, Just follow up the xml. Button_Selector.xml <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android">     <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/btn_pressed_bg" />     <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/btn_pressed_bg" />     <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/btn_pressed_bg" />     <item android:state_enabled="false" android:drawable="@drawable/btn_disabled"></item>     <item android:drawable="@drawable/btn_normal_bg" /> </selector> btn_pressed.xml <?xml version="1.0...

Show the Ad in ListView Footer

In ListView, If you want to show your Ad(Advertisement) on Footer view. Just Add this lines in your code: View footerView = ((LayoutInflater) getActivity().getSystemService( Context.LAYOUT_INFLATER_SERVICE)).inflate( R.layout.ads_banner_layout, null, false); WebView webView = (WebView) footerView.findViewById(R.id.ads_view); listview.addFooterView(footerView); listview.setAdapter(adapter); footerView is the view to inflate the ad_banner layout into your listview. Myself I'm using the webview to show the add, but its your choice to add some kind of different layouts and widgets in your footerview.

Get the Size of display in android

To get the current screen's width and height, just using DisplayMetrics  and WindowManager DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); int screenWidth = displayMetrics.widthPixels; int screenHeight = displayMetrics.heightPixels;

Email Address Validation

Lot of peoples validate their field by using field length or Regular Expressions . In this way, Email Addresses validation has been difficult some times. Format of Email Address: The format of email addresses is local-part@domain where the local-part may be up to 64 characters long and the domain name may have a maximum of 253 characters - but the maximum 256 characters length of a forward or reverse path restricts the entire email address to be no more than 254 characters.<sup id="cite_ref-0"> [1] </sup> The formal definitions are in RFC 5322 (sections 3.2.3 and 3.4.1) and RFC 5321 - with a more readable form given in the informational RFC 3696 <sup id="cite_ref-1">[2]</sup> and the associated errata. Supported Characters: The local-part of the email address may use any of these ASCII characters RFC 5322 Section 3.2.3: Uppercase and lowercase English letters (a–z, A–Z) (ASCII: 65-90, 97-122) Digits 0 to 9 (ASCII: 48-57) Cha...

Float Label Edit Text in android

Image
Last few days, i search some new UI on Edittext. Finally i found it  and its very awesome. Float Label EditText Meanwhile, some of jquery components only do this, but now android achieved it.  In android, such big form shows the hint text, but after text changed it will be disappear. Using TextView with EditText makes more screen space. Float Label Edit Text solves your problem. It's Support from version 2.2. It's also the one of best pluses. In XML: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       xmlns:tools="http://schemas.android.com/tools"     xmlns:floatlabel="http://schemas.android.com/apk/res-auto"      android:layout_width="match_parent"     android:layout_height="match_parent"     android:orientation="vertical"> <com.ind.floatlabeleditext.FloatLabelEditText     android:id="@+id/username"     android:layout_width="match_paren...