Skip to main content

Featured

Android studio “SDK tools directory is missing”

Following 2 possible solutions will resolve this problem :  Solution1 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:" Delete your  ~/.Android*  folders (losing all of your settings :/). Run Android Studio. It will show you a welcome wizard where it tries to download the SDK again (and fails due to my rubbish internet). Click the X on the wizard window. That will enable you to get to the normal welcome dialog. Go to Settings->Project Defaults->Project Structure and change the Android SDK location to the correct one. Solution 2 : To fix the problem, it was required that I list the path to my corporate PAC file by using  Configure -> "Appearance and Behavior" -> System Settings -> HTTP Proxy . I selected "Automatic proxy configuration url:&quo

code to append -(hyphen) to Text on EditText and allows to delete one digit at a time in Android

edt1=(EditText)findViewById(R.id.editText1);    
        edt1.addTextChangedListener(new TextWatcher() {
            public void afterTextChanged(Editable s) {
                //XXX do something                
            }
            public void beforeTextChanged(CharSequence s, int start, int count,int after) {
                    //XXX do something                
            }
            public void onTextChanged(CharSequence s, int start, int before, int count) {
                 ///Code  set listener for BackButton
                edt1.setOnKeyListener(new OnKeyListener() {                
                    @Override
                 public boolean onKey(View v, int keyCode, KeyEvent event) {
                     //You can identify which key pressed buy checking keyCode value with KeyEvent.KEYCODE_
                      if(keyCode != KeyEvent.KEYCODE_DEL && edt1.getText().length() !=0)
                      {
               
                if(edt1.getText().length()==5){
                String newtext = edt1.getText().toString() + "-";
                edt1.setText("");
                edt1.append(newtext);
                }
               
                      }                
                    
             return false ;      
                 }
         });}});       
        ///Code  set listener for BackButton
        edt1.setOnKeyListener(new OnKeyListener() {                
            @Override
            public boolean onKey(View v, int keyCode, KeyEvent event) {
                //You can identify which key pressed buy checking keyCode value with KeyEvent.KEYCODE_
                 if(keyCode == KeyEvent.KEYCODE_DEL && edt1.getText().length() !=0){
                     if(edt1.getText().length()==6)
                     {
                         String tempString=(edt1.getText().toString()).substring(0, edt1.getText().length()-2);
                         System.out.println("------tempString--"+tempString);
                         String newtext = tempString+edt1.getText().toString().charAt(edt1.getText().length()-2);
                         System.out.println("------newtext--"+newtext);
                         System.out.println("------char--"+edt1.getText().toString().charAt(edt1.getText().length()-2));
                         edt1.setText("");
                         edt1.append(newtext);
                     }                   
                     }               
            return false ;      
                }
        });

Comments