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

    package com.example.bbb;
    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[] name={"QQ斗地主","京东商城","QQ","天猫","UC浏览器","新浪微博","微信"};
        private int[] img={R.drawable.c,R.drawable.a,R.drawable.b,R.drawable.e,R.drawable.f,R.drawable.d,R.drawable.g};
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            mListView=(ListView)findViewById(R.id.lv);
            MyBaseAdapter mAdapter=new MyBaseAdapter();
            mListView.setAdapter(mAdapter);
        }
        class MyBaseAdapter extends BaseAdapter{
            @Override
            public int getCount() {
                return name.length;
            }
    
            @Override
            public Object getItem(int position) {
                return name[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.two,null);
                TextView appname=(TextView) view.findViewById(R.id.name);
                ImageView appimg=(ImageView)view.findViewById(R.id.img);
                appname.setText(name[position]);
                appimg.setBackgroundResource(img[position]);
                return view;
            }
    
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
    }
    <?xml version="1.0" encoding="utf-8"?>
    <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/lv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true" >
        </ListView>
    
    </RelativeLayout>
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="16dp">
        <ImageView
            android:id="@+id/img"
            android:layout_width="50dp"
            android:layout_height="50dp"
            android:layout_centerVertical="true"/>
        <RelativeLayout
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"      
            android:layout_marginLeft="10dp"
            android:layout_toRightOf="@+id/lv"
            android:layout_centerVertical="true">
    
        </RelativeLayout>
    
        <TextView
            android:id="@+id/name"
            android:text="QQ斗地主"
            android:textColor="#000000"
            android:textSize="21sp" 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="20dp"
            android:layout_toRightOf="@+id/img"
            />
    
    </RelativeLayout>

  • 相关阅读:
    Oracle 列顺序测试
    Java基于Servlet过虑器
    Java基于Servlet 验证吗
    WCF实例上下文
    WCF的行为与异常-------配置文件说明
    WCF异步
    WCF的通信
    分布式架构剖析
    [loj2542]「PKUWC2018」随机游走——min-max容斥+树上高消
    [bzoj4589]Hard Nim——SG函数+FWT
  • 原文地址:https://www.cnblogs.com/gjm717/p/11647844.html
Copyright © 2011-2022 走看看