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

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

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

    ZhipSoft.com
        冬去春來
            鄭重聲明:本Blog純屬個人學(xué)習(xí)、工作需要,記錄相關(guān)資料。請不要發(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("微風(fēng)");  
            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腳本關(guān)聯(lián)  
                    convertView = mInflater.inflate(R.layout.item_custom, null);  
                }  
                indexImage = (ImageView) convertView.findViewById(R.id.index_image);  
                indexText = (TextView) convertView.findViewById(R.id.index_text);  
                // 設(shè)置item中indexText的文本  
                indexText.setText(items.get(position).toString());  
                indexText.setTextColor(Color.RED);    
                // 設(shè)置item中ImageView的圖片  
                indexImage.setBackgroundResource(R.drawable.icon);  
                return convertView;  
            }  
        }  



            本Blog純屬個人學(xué)習(xí)、工作需要,記錄相關(guān)資料。請不要發(fā)表任何有人身攻擊的言論,謝謝! www.zhipsoft.cn
    posted on 2011-01-25 17:12 ZhipSoft 閱讀(6058) 評論(0)  編輯  收藏 所屬分類: AndRoid
    主站蜘蛛池模板: 亚洲第一成年免费网站| 三级毛片在线免费观看| 亚洲成AV人网址| 久久青草精品38国产免费| 亚洲国产精品久久网午夜| 四虎免费久久影院| 一个人免费视频在线观看www | 中文字幕av无码无卡免费| 久久久亚洲精华液精华液精华液| 精品国产亚洲一区二区在线观看| 日韩在线不卡免费视频一区| 亚洲精品无码久久久久牙蜜区| 国产亚洲综合网曝门系列| 欧美大尺寸SUV免费| 成人毛片100免费观看| 亚洲伊人久久精品| 中文字幕亚洲一区二区三区| 噼里啪啦电影在线观看免费高清| 二区久久国产乱子伦免费精品| 亚洲一区精彩视频| 亚洲国产美女精品久久久久∴| 精品国产一区二区三区免费看| 波多野结衣免费一区视频 | 亚洲欧洲精品在线| 国产午夜亚洲精品午夜鲁丝片| 毛片a级毛片免费播放100| 精品在线免费观看| 羞羞漫画页面免费入口欢迎你| 亚洲欧洲精品在线| 国产亚洲精品精华液| 国产午夜免费秋霞影院| 免费在线视频你懂的| 免费萌白酱国产一区二区三区 | 亚洲日本人成中文字幕| 亚洲人成人77777网站| 日本大片在线看黄a∨免费| 国产黄色免费网站| 午夜免费啪视频在线观看| 亚洲精品视频免费| 无码天堂va亚洲va在线va| 亚洲日韩精品无码专区加勒比|