• 列表视图


    package com.hanqi.testapp22;
    
    import android.os.Bundle;
    import android.support.v7.app.AppCompatActivity;
    import android.widget.ListView;
    import android.widget.SimpleAdapter;
    
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    
    public class TestActivity8 extends AppCompatActivity {
    ListView lv_1;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_test8);
            lv_1=(ListView)findViewById(R.id.lv_1);
            List<Map<String,Object>> lm=new ArrayList<Map<String,Object>>();
            Map<String,Object> map=new HashMap<String, Object>();
            map.put("img",R.drawable.f1);
            map.put("name","美食1");
            map.put("content", "美食1的内容");
            lm.add(map);
    
             map=new HashMap<String, Object>();
            map.put("img", R.drawable.f2);
            map.put("name", "美食2");
            map.put("content", "美食的内容");
            lm.add(map);
    
             map=new HashMap<String, Object>();
            map.put("img",R.drawable.f3);
            map.put("name","美食3");
            map.put("content", "美食3的内容");
            lm.add(map);
            map=new HashMap<String, Object>();
            map.put("img",R.drawable.f4);
            map.put("name","美食4");
            map.put("content","美食4的内容");
            lm.add(map);
            map=new HashMap<String, Object>();
            map.put("img",R.drawable.f5);
            map.put("name","美食5");
            map.put("content","美食5的内容");
            lm.add(map);
            map=new HashMap<String, Object>();
            map.put("img",R.drawable.f6);
            map.put("name","美食6");
            map.put("content","美食6的内容");
            lm.add(map);
            map=new HashMap<String, Object>();
            map.put("img",R.drawable.f7);
            map.put("name","美食7");
            map.put("content","美食7的内容");
            lm.add(map);
            map=new HashMap<String, Object>();
            map.put("img",R.drawable.f8);
            map.put("name","美食8");
            map.put("content","美食8的内容");
            lm.add(map);
            String[] strings={"img","name","content"};
            int [] ids={R.id.iv_1,R.id.tv_1,R.id.tv_2};
            SimpleAdapter simpleadapter=new SimpleAdapter(this,lm,
                    R.layout.simple_adapter,strings,ids);
            lv_1.setAdapter(simpleadapter);
        }
    }
    <?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">
        <ImageView
            android:layout_width="70dp"
            android:layout_height="70dp"
            android:src="@drawable/f1"
            android:id="@+id/iv_1"/>
        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical"
            android:layout_marginLeft="20dp"
            android:layout_marginTop="20dp"
            android:gravity="center_vertical">
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="名字=aaa"
                android:id="@+id/tv_1"/>
            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="内容=aaa"
                android:id="@+id/tv_2"/>
    
        </LinearLayout>
    
    </LinearLayout>
    View Code

  • 相关阅读:
    nfs-client-provisioner 利用NFS动态提供Kubernetes后端存储卷
    docker-compose简易编写和模板命令
    shell脚本自动过滤尝试多次连接ip并添加到系统黑名单
    Centos 升级glibc 亲测好用
    centos安装Jenkins报错
    centos8 安装docker启动失败
    cenots7 rpm 包升级ssh
    python备份文件(简易)
    Docker 容器基本操作(基础)
    Docker 环境下如何配置你的镜像(基础)
  • 原文地址:https://www.cnblogs.com/jiang2538406936/p/5504096.html
Copyright © 2020-2023  润新知