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

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


3.CursorAdapter.java

[java] view plain copy
  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

[java] view plain copy
  1. public abstract void bindView(View view, Context context, Cursor cursor);  
[java] view plain copy
  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

[java] view plain copy
  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

[java] view plain copy
  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);  

转载于:https://www.cnblogs.com/elfylin/archive/2012/04/06/2435356.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值