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>

  • 相关阅读:
    关于postman与shiro权限验证问题
    springboot对shiro进行mock单元测试
    深入理解spring注解之@ComponentScan注解
    springboot项目启动,但是访问报404错误
    通过jedis连接redis单机成功,使用redis客户端可以连接集群,但使用JedisCluster连接redis集群一直报Could not get a resource from the pool
    重装系统后ORACLE数据库恢复的方法
    ORA-03113: end-of-file on communication channel 解决方法
    ORA-03113:通信通道的文件结尾-完美解决方案
    由于Windows和Linux行尾标识引起脚本无法运行的解决
    在cmd命令行中弹出Windows对话框(使用mshta.exe命令)
  • 原文地址:https://www.cnblogs.com/ZERO-FLY/p/11642817.html
Copyright © 2011-2022 走看看