Posts

Showing posts with the label Android

Java - DecimalFormat

Android - Layout Error - Incorrect line ending

In layout file (xml file) if you found error: Incorrect line ending: found carriage return (\r) without corresponding newline (\n) . You should remove "\r", "\n" in your xml file. To solve this error , you can press "Ctrl + Shift + F" to remove "\r", "\n". It's so quickly.

Android - Resize ImageView

Android - EditText

g_editText = new EditText(this); g_editText.setText(""); g_editText.setEms(2); g_editText.setInputType(InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS); g_editText.setGravity(android.view.Gravity.CENTER); g_editText.addTextChangedListener(new TextWatcher() {                        @Override             public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {                     }                     @Override             public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {                     }           ...

Android - Pass Parameter to the other activity

Use "intent.putExtra()" to pass the parameter to the next activity. Example: EditText _search_text = (EditText) findViewById(R.id.editTextSearchText);             Intent _intent = new Intent(this, SearchResult.class); _intent.putExtra("search", _search_text.getText().toString().trim()); startActivity(_intent); this.finish(); And on the "onCreate()" function of the receive activity, receive parameter by: Example: String _search_text; Bundle extras = getIntent().getExtras(); if (extras != null) {      _search_text = extras.getString("search"); }

Android - onKeyListener

EditText _search_text = (EditText) findViewById(R.id.editTextSearchText); _search_text Text . setOnKeyListener ( new OnKeyListener () { public boolean onKey ( View v , int keyCode , KeyEvent event ) { if (event.getAction() == KeyEvent.ACTION_DOWN) { switch (keyCode) { case KeyEvent.KEYCODE_ENTER: this.goToSearchResultPage(); return true; default: break; } } return false; } });