Layout:-
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" >
<requestFocus />
</AutoCompleteTextView>
</LinearLayout>
Java Code:-
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class AddCompany extends Activity {
private AutoCompleteTextView autotext;
private String[] objects={"abc","xyz","afdf"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profilelist);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.id.textView2, objects);
autotext=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
autotext.setThreshold(3);
autotext.setAdapter(adapter);
// TODO Auto-generated method stub
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="AutoCompleteTextView" >
<requestFocus />
</AutoCompleteTextView>
</LinearLayout>
Java Code:-
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
public class AddCompany extends Activity {
private AutoCompleteTextView autotext;
private String[] objects={"abc","xyz","afdf"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.profilelist);
ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, R.id.textView2, objects);
autotext=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
autotext.setThreshold(3);
autotext.setAdapter(adapter);
// TODO Auto-generated method stub
}
}
No comments:
Post a Comment