<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    ZhipSoft.com
        冬去春來
            鄭重聲明:本Blog純屬個人學習、工作需要,記錄相關資料。請不要發(fā)表任何有人身攻擊的言論,謝謝!!www.ZhipSoft.com
    posts - 94,comments - 149,trackbacks - 0

    程序xml文件:

    list_view.xml://主文件

    view plaincopy to clipboardprint?
    <?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 
       <ListView android:id="@+id/list_view" 
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent" 
          android:divider="#ffc9c9c9" 
          android:dividerHeight="1px"/> 
    </LinearLayout> 
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="vertical"
       android:layout_width="fill_parent"
       android:layout_height="fill_parent">
       <ListView android:id="@+id/list_view"
          android:layout_width="fill_parent"
          android:layout_height="fill_parent"
          android:divider="#ffc9c9c9"
          android:dividerHeight="1px"/>
    </LinearLayout>

    item_custom.xml://定義想要的布局效果

    view plaincopy to clipboardprint?
    <?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="horizontal" 
         android:layout_width="wrap_content" 
         android:layout_height="58px" 
         android:gravity="center_vertical" 
         >     
         <ImageView android:id="@+id/index_image" 
             android:layout_width="wrap_content" 
             android:layout_height="wrap_content" 
             > 
          </ImageView> 
            
          <TextView android:id="@+id/index_text" 
             android:layout_width="wrap_content" 
             android:layout_height="50px" 
             android:textSize="20sp" 
             android:layout_marginLeft="10px"          
             android:gravity="center" 
             android:textColor="#ff000000"> 
          </TextView>      
    </LinearLayout> 
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:orientation="horizontal"
         android:layout_width="wrap_content"
         android:layout_height="58px"
         android:gravity="center_vertical"
         >  
         <ImageView android:id="@+id/index_image"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             >
          </ImageView>
         
          <TextView android:id="@+id/index_text"
             android:layout_width="wrap_content"
             android:layout_height="50px"
             android:textSize="20sp"
             android:layout_marginLeft="10px"       
             android:gravity="center"
             android:textColor="#ff000000">
          </TextView>   
    </LinearLayout>

    程序代碼:

    view plaincopy to clipboardprint?
    import java.util.ArrayList;  
    import java.util.List;  
    import android.app.Activity;  
    import android.content.Context;  
    import android.graphics.Color;  
    import android.os.Bundle;  
    import android.view.LayoutInflater;  
    import android.view.View;  
    import android.widget.BaseAdapter;  
    import android.widget.ImageView;  
    import android.widget.ListView;  
    import android.widget.TextView;  
    public class CustomListview extends Activity {  
        private ListView mListView;  
        private List<String> items;     
        @Override 
        public void onCreate(Bundle savedInstanceStated) {  
            super.onCreate(savedInstanceStated);  
            setContentView(R.layout.list_view);  
            mListView = (ListView) findViewById(R.id.list_view);  
            fillArray();  
            mListView.setAdapter(new CustomListAdapter(this));  
        }  
          
        private void fillArray() {  
            items = new ArrayList<String>();  
            items.add("白天");  
            items.add("黑天");  
            items.add("多云");  
            items.add("微風");  
            items.add("晴天");  
        }  
        class CustomListAdapter extends BaseAdapter {  
            private LayoutInflater mInflater;  
            private Context mContext = null;  
            public CustomListAdapter(Context context) {  
                mContext = context;  
                mInflater = LayoutInflater.from(mContext);  
            }  
            public Object getItem(int arg0) {  
                // TODO Auto-generated method stub  
                return items.get(arg0);  
            }  
            public long getItemId(int position) {  
                // TODO Auto-generated method stub  
                return position;  
            }  
            public int getCount() {  
                // TODO Auto-generated method stub  
                return items.size();  
            }  
            public View getView(int position, View convertView,  
                    android.view.ViewGroup parent) {  
                final ImageView indexImage;  
                final TextView indexText;  
                if (convertView == null) {  
                    // 和item_custom.xml腳本關聯  
                    convertView = mInflater.inflate(R.layout.item_custom, null);  
                }  
                indexImage = (ImageView) convertView.findViewById(R.id.index_image);  
                indexText = (TextView) convertView.findViewById(R.id.index_text);  
                // 設置item中indexText的文本  
                indexText.setText(items.get(position).toString());  
                indexText.setTextColor(Color.RED);    
                // 設置item中ImageView的圖片  
                indexImage.setBackgroundResource(R.drawable.icon);  
                return convertView;  
            }  
        }  



            本Blog純屬個人學習、工作需要,記錄相關資料。請不要發(fā)表任何有人身攻擊的言論,謝謝! www.zhipsoft.cn
    posted on 2011-01-25 17:12 ZhipSoft 閱讀(6059) 評論(0)  編輯  收藏 所屬分類: AndRoid
    主站蜘蛛池模板: a级毛片免费网站| 亚洲国产精品乱码在线观看97 | 亚洲综合偷自成人网第页色| 中文字幕在线成人免费看| 四虎永久在线精品免费影视 | 亚洲国产成人精品无码区在线网站| 99久久婷婷免费国产综合精品| 亚洲第一黄片大全| 在线观看亚洲专区| 日韩成人免费视频播放| 亚洲最大的成人网站| 99在线视频免费观看视频| 亚洲精品美女久久久久9999| 99热在线免费播放| 亚洲精品人成在线观看| 日韩免费在线视频| 亚洲情a成黄在线观看动漫尤物| 久久免费看少妇高潮V片特黄| 亚洲国产精品嫩草影院在线观看 | 黄色a级免费网站| 亚洲av再在线观看| 国产午夜无码片免费| 亚洲成av人影院| 久久精品无码专区免费东京热| 久久亚洲精品成人av无码网站| 91精品免费国产高清在线| 亚洲一区二区三区免费观看| 成人毛片视频免费网站观看| 校园亚洲春色另类小说合集| 亚洲国产专区一区| 久久免费视频观看| 亚洲一区二区三区不卡在线播放| 91在线品视觉盛宴免费| 免费亚洲视频在线观看| 国产成人麻豆亚洲综合无码精品 | 亚洲av无码一区二区三区乱子伦 | 国产av无码专区亚洲国产精品| 在线观看人成视频免费无遮挡| 久久精品国产亚洲精品2020| 成年女人毛片免费播放视频m| 免费国产污网站在线观看不要卡|