PowenKo, Android, Tutorial 014, UI, AutoCompleteTextView

August 25, 2011   ·   0 Comments

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />

<AutoCompleteTextView android:id="@+id/autoCompleteTextView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:completionThreshold="1"
/>    
    
</LinearLayout>

 

package com.powenko.Tutorial_UI_AutoCompleteTextView;


import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;

public class Tutorial_UI_AutoCompleteTextViewActivity extends Activity {
	
	AutoCompleteTextView myAutoComplete;
	String item[]={
	  "January", "February", "March", "April",
	  "May", "June", "July", "August",
	  "September", "October", "November", "December",
          "PowenKo","PowenKo.com"
	};


	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
         
        
        myAutoComplete = (AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
        
        myAutoComplete.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, item));
        

        myAutoComplete.addTextChangedListener(new TextWatcher() {
        	 
            public void afterTextChanged(Editable s) {
              //  ((TextView)findViewById(R.id.numcaratteri)).setText(String.format(getString(R.string.caratteri), s.length()));
         
            }
         
            public void beforeTextChanged(CharSequence s, int start, int count,
                    int after) {
                // TODO Auto-generated method stub
         
            }
         
            public void onTextChanged(CharSequence s, int start, int before,
                    int count) {
                // TODO Auto-generated method stub
         
            }
         
        });
        
    }
}

 

 

 

 

 

 

 

 

 

 

 

sample code:

Tutorial_UI_AutoCompleteTextViewActivity

shareShare on FacebookShare on Google+Share on LinkedInEmail this to someonePrint this pageBuffer this pageDigg thisFlattr the authorShare on RedditPin on PinterestShare on StumbleUponShare on TumblrTweet about this on Twitter

By


Readers Comments (0)


You must be logged in to post a comment.

PowenKo’s Online Store

powenko_arduinoBook
Android7

Amazon

adsbygoogle

Recent Posts

Categories

Amazon