Open top menu

 

How to implement ExtractEditText in android ?

In this blog explain how to used ExtractEditText in android. The ExtractEditText extends EditText class. the widgets used android API Level 3.Specialization of EditText for showing and intracting with the extract text in a full screen input method.


private boolean extractedTextModeWillBeStarted() {
    if (!(this instanceof ExtractEditText)) {
        final InputMethodManager imm = InputMethodManager.peekInstance();
        return  imm != null && imm.isFullscreenMode();
    }
    return false;
}











Read more



Material Design Overview in Android?

Google introduced in last Year's ,the design describing it as User Interface That's - bold Graphic design ,Beautiful,motion and interaction design Across Platforms and Devices. Android Material design introduced in Android Version API 21 .In material design used lot of new thing like :-

  • Material Theme.
  • Custom Widgets.
  • Vector Drawables.
  • Custom Animation .
  • New widgets for Custom Theme

The Material theme provide new style for you app,system widgets let you set there color palette and defualt Animations for touch feedbach and activity transitions.




Read more



Example- CheckedTextView In Android ?


In this blog explain how to work CheckedTextView Widgets in android. the CheckedTextView Added API 1 . An extension to textview that support The checkble Interface and display. 

this is used in Listview where in SinglechoiceMode .



android:checkMark - Drawable used for the check mark graphic .

android:checkMarkTint - Tint to apply check mark.

android:checkMarkTintMode- Blending Mode used to apply tint check Mark.




content_main.xml
...................................................................................................................................................................


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
android:layout_width="fill_parent"    
android:layout_height="fill_parent"   
android:orientation="vertical"    
android:background="#ffffff"     >
    
<ImageView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:id="@+id/imageView"            
android:layout_gravity="center"            
android:src="@drawable/my_heder_img">
</ImageView>

    
<CheckedTextView        
android:layout_width="fill_parent"        
android:layout_marginTop="50dp"        
android:layout_marginLeft="10dp"        
android:textSize="18dp"        
android:layout_height="wrap_content"        
android:text="CheckedTextView"        
android:id="@+id/checkedTextView"        
android:checkMark="?android:attr/listChoiceIndicatorMultiple"        
android:checked="false"         />


</LinearLayout>




...................................................................................................................................................................


MainActivity.Java
...................................................................................................................................................................

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.CheckedTextView;

public class MainActivity extends Activity  {


    @Override    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.content_main);

        final CheckedTextView ctv = (CheckedTextView) findViewById(R.id.checkedTextView);
        ctv.setOnClickListener(new View.OnClickListener() {
            @Override            public void onClick(View v) {
                if (ctv.isChecked())
                    ctv.setChecked(false);
                else                    ctv.setChecked(true);

            }
        });


    }
}

...................................................................................................................................................................

try this...........






































































Read more


Android TextWatcher-Example?

In this tutorial show  how to implement Textwatcher in android? explain below....

Textwatcher is usefull public method in android,Textwatcher is watch input text instantly then you can update data instantly. for example validate emailId, i have implement email Validation TextWatcher .

The TextWatcher  used Some Public Method.

Public Method

This mehod is called notify somewhere text has been change.it is legitimate to make further changes.

beforTextChanged()

public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    
}

this method is called to within s the count character beginning at start are about to be replace by the new text with length after

onTextChanged()

@Overridepublic void onTextChanged(CharSequence s, int start, int before, int count) {

}


this method is called to within s the count character beginning at start  have just replace  text had length before.

content_main.xml.
...................................................................................................................................................................


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    
android:layout_width="fill_parent"    
android:layout_height="fill_parent"   
android:orientation="vertical"   
android:background="#ffffff"     >
 
<ImageView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:id="@+id/imageView"            
android:layout_gravity="center"            
android:src="@drawable/my_heder_img">
</ImageView>

    
<EditText        
android:layout_width="match_parent"        
android:layout_height="50dp"        
android:layout_margin="30dp"        
android:id="@+id/editText2"        
android:padding="10dp"        
android:background="@drawable/register_cover"        
android:layout_gravity="center_horizontal" />


</LinearLayout>







...................................................................................................................................................................



ActivityMain.java
...................................................................................................................................................................

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

public class MainActivity extends Activity  {
    String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";
    EditText edittextEmailId;
 @Override    
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.content_main);
edittextEmailId=(EditText)findViewById(R.id.editText2);
edittextEmailId.addTextChangedListener(new TextWatcher() {
 @Override           
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
 // instantly get input text                
String email = edittextEmailId.getText().toString().trim();
 //Check Email Pattern instantly                
if (email.matches(EMAIL_PATTERN) && s.length() > 0)
                
{
                   
 edittextEmailId.setError(null);
 edittextEmailId.requestFocus();
 }
                
else                
{
  edittextEmailId.setError("Invalid email address");
  edittextEmailId.requestFocus();
                
}
            
}



@Override            
public void onTextChanged(CharSequence s, int start, int before, int count) {

}

@Override            
public void afterTextChanged(Editable s) {

            }
        });



    }
}





...................................................................................................................................................................

















Read more


EXAMPLE- Difference Between ToggleButton and SwitchButton in android?


In this blog explain what type of difference ToggleButton and Switch Button...

Toggle Button

 You can add Toggle button in your  Layout with the help of object.The Toggle Button are Available 
Android API Level 14.the Toggle Button used two State ON and OFF.

if you need Change button state via this method.

setChecked();




Read More...


Switch Button

The switch button work as same Toggle Button But Switch Button available Android API level 1 and show state clear ON and OFF. Means the user interface/Desgin is very simple and basic ,you can Drag thumb back and forward. 





Read More......
Read more