android how to limit the lines on edittext

view story

http://stackoverflow.com – I want to have 5 lines in an edittext, so the user can press Enter just 4 times, I tried like this but still can't work myEtidtext.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { // TODO Auto-generated method stub // if enter is pressed start calculating if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) { // get EditText text String text = ((EditText) v).getText().toString(); // find how many rows it cointains int editTextRowCount = text.spli (HowTos)