zoukankan      html  css  js  c++  java
  • 作业六

    package com.example.zuoyesix;
    
    import android.support.v7.app.ActionBarActivity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    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 ActionBarActivity {
    
        private String[] t = { "京东商城", "QQ", "QQ斗地主", "新浪微博", "天猫", "UC游览器","微信"};
        
        private int[] i = { R.drawable.jd, R.drawable.qq,
                R.drawable.ddz, R.drawable.wb, R.drawable.tm,
                R.drawable.uc,R.drawable.wx };
    
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
    
            ListView lv = (ListView) findViewById(R.id.listView1);
        
            Myadapter md = new Myadapter();
            
            lv.setAdapter(md);
        }
    
        class Myadapter extends BaseAdapter {
    
            @Override
            public int getCount() {
            
                return t.length;
            }
    
            @Override
            public Object getItem(int position) {
            
                return t[position];
            }
    
            @Override
            public long getItemId(int position) {
            
                return position;
            }
    
            @Override
            public View getView(int position, View convertView, ViewGroup parent) {
        
                View view=View.inflate(MainActivity.this, R.layout.list_item, null);
                TextView tv1=(TextView)view.findViewById(R.id.title);
                ImageView iv=(ImageView)view.findViewById(R.id.iv);
                
                tv1.setText(t[position]);
                iv.setBackgroundResource(i[position]);
                
                return view;
            }
    
        }
    
    }
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
        <ListView
            android:id="@+id/listView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"/>
    </LinearLayout>
    <?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">
    
        <LinearLayout
            android:layout_margin="18dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
    
            <ImageView
                android:id="@+id/iv"
                android:layout_width="60dp"
                android:layout_height="60dp" />
    
            <TextView
                android:id="@+id/Text"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="center_vertical"
                android:textSize="35sp"
                android:layout_marginLeft="10dp"/>
        </LinearLayout>
    </LinearLayout>

  • 相关阅读:
    主页面
    EasyUI写的登录界面
    SpringMVC学习笔记二第一个小的程序
    springmvc学习笔记一框架的理解
    mybitis学习笔记
    cheng gong de daima
    JQuery中如何使用事件来出发Ajax
    按照用户名和角色查询用户liferay
    在liferay中如何使用Ajax的请求
    [奇葩说]
  • 原文地址:https://www.cnblogs.com/ZERO-FLY/p/11642817.html
Copyright © 2011-2022 走看看