ListView Display and File to Uri

为君一笑 提交于 2020-02-01 00:25:56

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);  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!