看到现在很多的手机拨号界面的号码输入框,都是自动提示的,我现在有个开发板,它的拨号框没有自动提示,我就修改了下源码,将原来的EditText该为AutoCompleteTextView ,然后将修改过的程序烧进去的时候,点击拨号想进去拨号界面就出错了。...请问各位有做过这个这方面的吗,有修改过android源码这块的吗?麻烦给我指正一下,谢谢,,,

解决方案 »

  1.   

    下面是我修改之后涉及到这个输入框的源码:
     1.private AutoCompleteTextView mDigits;
    2.public void afterTextChanged(Editable input) {
            if (SpecialCharSequenceMgr.handleChars(this, input.toString(), mDigits)) {
                // A special sequence was entered, clear the digits
                mDigits.getText().clear();
            }        if (!isDigitsEmpty()) {
                mDigits.setBackgroundDrawable(mDigitsBackground);
            } else {
                mDigits.setCursorVisible(false);
                mDigits.setBackgroundDrawable(mDigitsEmptyBackground);
            }        updateDialAndDeleteButtonEnabledState();
        }
    3.mDigits = (AutoCompleteTextView) findViewById(R.id.digits);
            mDigits.setKeyListener(DialerKeyListener.getInstance());
            mDigits.setOnClickListener(this);
            mDigits.setOnKeyListener(this);
            
            //set the auto phoneNumber adapter
            ArrayAdapter<String> adapter=new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,getNumFromPhoneBook());
            mDigits.setAdapter(adapter);
    代码太多了,都是android系统的源码。。好麻烦
      

  2.   

     private class MyHandler extends Handler{
    @Override
    public void handleMessage(Message msg) {
    super.handleMessage(msg);
    switch(msg.what){
    case SEARCHING_STATE:
    lbMsg.setText(TwelveKeyDialer.this.getResources().getString(R.string.search_results_searching));
    bar.setVisibility(View.VISIBLE);
    break;
    case SEARCHED_STATE:
    Uri uri1 = ContactsContract.Contacts.CONTENT_URI;
         Uri uri2 = ContactsContract.CommonDataKinds.Phone.CONTENT_URI;
         Cursor cursor = TwelveKeyDialer.this.getContentResolver().query(uri2, null, ContactsContract.CommonDataKinds.Phone.NUMBER + " like '%" + mDigits.getText().toString().replace("-", "").trim() + "%'", null, null);
         String strID = null;
         String displayName = null;
         String phoneNum = null;
         if(cursor.moveToNext()){
         strID = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
         phoneNum = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
         }
         cursor.close();
         Cursor c = TwelveKeyDialer.this.getContentResolver().query(uri1, null,ContactsContract.Contacts._ID + "=" + strID, null, null);
         if(c.moveToNext()){
         displayName = c.getString(c.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
         }
         c.close();
         if(null != displayName){
         phoneNum = phoneNum.replace("-", "").trim();
         lbMsg.setText(displayName + "\t" + phoneNum);
         isExist = true;
         }else{
         lbMsg.setText(getResources().getString(R.string.recentCalls_addToContact) + ":" + mDigits.getText().toString());
         isExist = false;
         }
    bar.setVisibility(View.INVISIBLE);
    break;
    default:break;
    }

    }
        
        }我还是用的EditText,就是在下面用了个TextView来显示提示
      

  3.   

     public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // Do nothing
        }    public void onTextChanged(CharSequence input, int start, int before, int changeCount) {
            // Do nothing*#06#
            // DTMF Tones do not need to be played here any longer -
            // the DTMF dialer handles that functionality now.
         mHandler.sendEmptyMessage(0);
        }    public void afterTextChanged(Editable input) {
            if (SpecialCharSequenceMgr.handleChars(this, input.toString(), mDigits)) {
                // A special sequence was entered, clear the digits
                mDigits.getText().clear();
            }        if (!isDigitsEmpty()) {
                mDigits.setBackgroundDrawable(mDigitsBackground);
            } else {
                mDigits.setCursorVisible(false);
                mDigits.setBackgroundDrawable(mDigitsEmptyBackground);
            }
            mHandler.sendEmptyMessageDelayed(1, 1000);
            updateDialAndDeleteButtonEnabledState();
        }