于是刚才抽空去试了下,成功了简单说就是实现一个AutoCompleteTextView的子类,重写showDropDown方法,这个方法调用了buildDropDown方法,但buildDropDown是私有的方法,无法重写
重写的showDropDown先调用父类的showDropDown方法,然后通过反射获取mDropDownList对象,调用dropdown.setVerticalFadingEdgeEnabled(false);即可

解决方案 »

  1.   

    private static Field getField(Class<?> clazz, String fieldName)
    throws NoSuchFieldException {
    Field field = null;
    try {
    field = clazz.getDeclaredField(fieldName);
    } catch (NoSuchFieldException e) {
    try {
    field = clazz.getField(fieldName);
    } catch (NoSuchFieldException e1) {
    if (clazz.getSuperclass() == null) {
    throw e1;
    } else {
    field = getField(clazz.getSuperclass(), fieldName);
    }
    }
    }
    return field;
    }public static Object getFieldValue(Object instance, String fieldName)
    throws NoSuchFieldException, IllegalArgumentException,
    IllegalAccessException {
    Field field = getField(instance.getClass(), fieldName);
    field.setAccessible(true);
    return field.get(instance);
    }
    这个是从以前写的反射工具类里抽出来的两个方法public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
    android.R.layout.simple_dropdown_item_1line, autoStr);
    LinearLayout layout = new LinearLayout(this);
    AutoCompleteTextView myAutoCompleteTextView = new AutoCompleteTextView(
    this) {
    public void showDropDown() {
    super.showDropDown();
    try {
    View dropdown = (View) ReflectUtils.getFieldValue(
    this, "mDropDownList");
    dropdown.setVerticalFadingEdgeEnabled(false);
    } catch (IllegalArgumentException e) {
    e.printStackTrace();
    } catch (NoSuchFieldException e) {
    e.printStackTrace();
    } catch (IllegalAccessException e) {
    e.printStackTrace();
    }
    }
    };
    myAutoCompleteTextView.setAdapter(adapter);
    layout.addView(myAutoCompleteTextView, new LinearLayout.LayoutParams(
    LinearLayout.LayoutParams.FILL_PARENT,
    LinearLayout.LayoutParams.WRAP_CONTENT));
    setContentView(layout);
    }其实我也很懒……没有去专门写一个AutoCompleteTextView的子类而是直接搞了一个匿名内部类,连xml也懒得写直接用代码布的局……主要看那个匿名内部类就好了