• 第六次作业


    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >
      
        <ListView
                android:id="@+id/iv"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:listSelector="#fefefefe"
                android:scrollbars="none"
               />
    </RelativeLayout>
    <?xml version="1.0" encoding="UTF-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal" >
    
        <ImageView
            android:id="@+id/Iv"
            android:layout_width="70dp"
            android:layout_height="70dp"
            />
         <TextView 
             android:id="@+id/tv"
             android:layout_width="match_parent"
             android:layout_height="70dp"
             android:layout_marginLeft="10dp"
             android:gravity="center_vertical"
             android:textSize="25dp"
            />
    
         
    </LinearLayout>
    package com.example.project;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.BaseAdapter;
    import android.widget.ImageView;
    import android.widget.ListView;
    import android.widget.TextView;
    
    public class MainActivity extends Activity {
        private ListView mListView;
        private String[] Iv = {"京东商城","QQ","QQ斗地主","新浪微博","天猫商城","UC浏览器","微信"};
        private int[] icons = {R.drawable.jd,R.drawable.qq,R.drawable.ddz,R.drawable.wb,R.drawable.tm,R.drawable.uc,R.drawable.wx};
        
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            mListView =(ListView) findViewById(R.id.iv);
            MyBaseAdapter mAdapter =new MyBaseAdapter();
            mListView.setAdapter(mAdapter);
        }
        class  MyBaseAdapter extends  BaseAdapter{
            public  int getCount(){
                return Iv.length;
            }
            public  Object getItem(int posision){
                return Iv[posision];
            }
            public long getItemId(int position){
                return position;
            }
            @Override
            public View getView(int arg0, View arg1, ViewGroup arg2) {
                // TODO Auto-generated method stub
                return null;
            }
        }
        public View getView(int position, View converView, ViewGroup parent) {
            View view =View.inflate(MainActivity.this,R.layout.list_item,null);
            TextView title =(TextView) view.findViewById((R.id.tv));
            title.setText(Iv[position]);
            ImageView lv=(ImageView)view.findViewById(R.id.Iv);
            lv.setBackgroundResource(icons[position]);
            return view;
    
        }
        
    }

  • 相关阅读:
    git命令
    svg学习系列02-简单的svg图形和线条
    svg学习系列01-svg简介
    jQuery分页插件
    svg简介
    css3选择器
    sublime使用
    HTML5新特性
    html新的语义化标签和表单控件
    DOM详解
  • 原文地址:https://www.cnblogs.com/rongrui/p/11645085.html
Copyright © 2020-2023  润新知