ListView Display and File to Uri

How can adapter display the content of the listview.

1.AbsListView.java

  1. protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
  2.   .......  
  3.   final View child = obtainView(0, mIsScrap);  
  4.   .....  
  5. }  

//one item, called one time.
2.AbsListView.java

  1.     View obtainView(int position, boolean[] isScrap) {  
  2. ....  
  3. child = mAdapter.getView(position, scrapView, this);  
  4. ....  
  5. }  


3.CursorAdapter.java

  1.     public View getView(int position, View convertView, ViewGroup parent) {  
  2.         .....  
  3.         if (convertView == null) {  
  4.             v = newView(mContext, mCursor, parent);  
  5.         } else {  
  6.             v = convertView;  
  7.         }  
  8.         bindView(v, mContext, mCursor);  
  9.         return v;  
  10.     }  


4.CursorAdapter.java

  1. public abstract void bindView(View view, Context context, Cursor cursor);  
  1. public abstract View newView(Context context, Cursor cursor, ViewGroup parent);  

 

//so override the the bindView and newView. and we just need the return the item view not the listview. 

all adapters getView

  1. View getView(int position, View convertView, ViewGroup parent);  

so for what adapter, we just need to return one item's view.

 

file to url

  1. public static Uri fromFile(File file) {  
  2.     if (file == null) {  
  3.         throw new NullPointerException("file");  
  4.     }  
  5.   
  6.     PathPart path = PathPart.fromDecoded(file.getAbsolutePath());  
  7.     return new HierarchicalUri(  
  8.             "file", Part.EMPTY, path, Part.NULL, Part.NULL);  

posted @ 2012-04-06 21:47  cascais  阅读(194)  评论(0编辑  收藏  举报