Code example for EditText

Methods: addTextChangedListenersetMaxLinessetMinLinessetOnEditorActionListenersetText, setLayoutParams

2
		mContainer = ( LinearLayoutIMETrap ) new LinearLayoutIMETrap ( sContext );
		mContainer.setLayoutParams ( new LinearLayout.LayoutParams ( LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ));
		mContainer.setOrientation ( LinearLayout.VERTICAL );
		mContainer.setMainActivity ( activity );
 
		mKeyInTextView = new EditText ( activity );
 
		mKeyInTextView.setText ( "" );
		mKeyInTextView.setMinLines ( 1 );
		mKeyInTextView.setMaxLines ( 1 );
		 
		mKeyInTextView.addTextChangedListener ( new TextWatcher () {
 
			public void afterTextChanged ( Editable s ) {
 
   				mKeyString = s.toString ();
			} 
 
			public void beforeTextChanged ( CharSequence s, int start, int count, int after ) {
 
				mKeyString = s.toString ();
			} 
 
			public void onTextChanged ( CharSequence s, int start, int before, int count ) {
 
				mKeyString = s.toString ();
				mKeyIsReady = true;
			} 
		}); 
		 
		mKeyInTextView.setOnEditorActionListener(new OnEditorActionListener() {
		    @Override 
		    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
		        if (actionId == EditorInfo.IME_ACTION_DONE) {
					mTextIsReady = true;
		        } 
		        return false; 
		    } 
		}); 
 
		// Create the fake EditText, and push it outside the margins so that its not visible. 
		LinearLayout.LayoutParams paramsKeyInTextView = new LinearLayout.LayoutParams ( LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT );
 
		// re-set the Margins so that the field is hidden. 
		paramsKeyInTextView.setMargins ( 0, 64, 0, 0 );
		mKeyInTextView.setLayoutParams ( paramsKeyInTextView );
		 
	} 
 
	public static LinearLayoutIMETrap getContainer () { 
		return mContainer;