Android Open Source - Text-Edit-for-Android File Auto Complete Array Adapter






From Project

Back to project page Text-Edit-for-Android.

License

The source code is released under:

GNU General Public License

If you think the Android project Text-Edit-for-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package org.paulmach.textedit;
//from  w  ww.  jav a2s.c  o  m
import java.io.File;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

/****************************************************************
 * FileAutoCompleteArrayAdapter
 *    To customize what is displayed in the autocomplete 
 *    options we use this class, getView() is where the change
 *    happens. */
public class FileAutoCompleteArrayAdapter extends ArrayAdapter<String>
{
  // just a basic constructor
  public FileAutoCompleteArrayAdapter(Context context, int resource, List<String> objects) {
    super(context, resource, objects);
  }

  public View getView(int position, View convertView, ViewGroup parent) 
  {
    // get the view that would normally be returned
    TextView tv = (TextView) super.getView(position, convertView, parent);
    
    // update the text accordingly
    File f = new File(tv.getText().toString());
    if (f.isDirectory())
      tv.setText(f.getName() + "/");
    else
      tv.setText(f.getName());

    // change some options
    tv.setPadding(10,3,3,3);
    tv.setTextSize(18.0f);
    
    return (View) tv;  // return the view
  }
  
} // end class AutoCompleteArrayAdapter





Java Source Code List

org.paulmach.textedit.ClearRecentFileListPreference.java
org.paulmach.textedit.ClearSearchSuggestions.java
org.paulmach.textedit.ColorPreference.java
org.paulmach.textedit.DefaultDirPreference.java
org.paulmach.textedit.EditPreferences.java
org.paulmach.textedit.FileAutoCompleteArrayAdapter.java
org.paulmach.textedit.FileBrowser.java
org.paulmach.textedit.FileViewArrayAdapter.java
org.paulmach.textedit.FontSizePreference.java
org.paulmach.textedit.FontTypePreference.java
org.paulmach.textedit.SearchSuggestions.java
org.paulmach.textedit.WarrantyPreference.java
org.paulmach.textedit.pmTextEdit.java