AUTO TEXT ANDROID TUTORIAL
First Create main.xml file....
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="24dp"
android:text="City :"
android:textAppearance="?android:attr/textAppearanceLarge" />
<AutoCompleteTextView
android:id="@+id/auto"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:textColor="@android:color/black"
android:ems="10" >
</AutoCompleteTextView>
</RelativeLayout>
After create MainActivity.java file....
public class MainActivity extends Activity {
String co[] = {"Nishal","Niky","Nikunj","Sachin","Sahil","Sanjay"}; // here enter your value
AutoCompleteTextView at;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
at = (AutoCompleteTextView)findViewById(R.id.auto);
at.setAdapter(new ArrayAdapter<String>(this,R.layout.list,co));
}
}
OUTPUT :-
WRITE YOUR STING VALUE IN EDIT TEXT AFTER FILTER EDIT TEXT.....
First Create main.xml file....
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="24dp"
android:text="City :"
android:textAppearance="?android:attr/textAppearanceLarge" />
<AutoCompleteTextView
android:id="@+id/auto"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView1"
android:layout_alignBottom="@+id/textView1"
android:layout_alignParentRight="true"
android:textColor="@android:color/black"
android:ems="10" >
</AutoCompleteTextView>
</RelativeLayout>
After create MainActivity.java file....
public class MainActivity extends Activity {
String co[] = {"Nishal","Niky","Nikunj","Sachin","Sahil","Sanjay"}; // here enter your value
AutoCompleteTextView at;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
at = (AutoCompleteTextView)findViewById(R.id.auto);
at.setAdapter(new ArrayAdapter<String>(this,R.layout.list,co));
}
}
OUTPUT :-
WRITE YOUR STING VALUE IN EDIT TEXT AFTER FILTER EDIT TEXT.....
OUTPUT |
No comments :
Post a Comment