Android Useful Tips

Today we are learn some important tips which is use each and every android app.

1. Capitalize Every First letter of a Word in EditText
If any buddy want to capitalize the first letter of every word in a EditText,
assign android:inputType=”textCapWords” to EditText.

The same process by programatically also as shown below.
TextView txtCapitalize = (TextView) findViewById(R.id.txtCapitalize);
txtCapitalize.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_WORDS);  

2. Hide  the keypad in Android
 public static void hideKeyboard(MainActivity activity) {
        InputMethodManager imm = (InputMethodManager) activity.getSystemService(MainActivity.INPUT_METHOD_SERVICE);

        View view = activity.getCurrentFocus();

        if (view == null) {
            view = new View(activity);
        }
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }



3.How to  start or stot adb from command line
If you start or stop the adb using the command prompt please follow blow processs

1.first open CMD
Note:-Before you execute the commands in CMD make sure that you added the adb tool to your Environment Variables path.

2.Killing adb
 adb kill-server 

3.Starting adb
 adb start-server  

4. Detect back button press in android
Override the onBackPressed() method and take the action inside this function.
@Override
    public void onBackPressed() {
        // Write code here
        super.onBackPressed();
    }





1 comments:

thanks manish good job...!

please let me know about android N

Reply