关闭

ListView

26人阅读 评论(0) 收藏 举报

List View


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    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:orientation="horizontal"
    tools:context="com.example.scxh.para.ParaMainActivity">
    <ListView
        android:id="@+id/t1"
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:src="@drawable/a11"/>
</LinearLayout>
xml代码如下:

package com.ittx.android1601.adapter;


import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.ArrayAdapter;
import android.widget.ListView;


import com.ittx.android1601.R;


public class MyArrayAdpaterActivity extends AppCompatActivity {
    public ListView mListView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_array_adpater_layout);
        // TODO: 2016/6/1 实例化控件ListView 
        mListView = (ListView) findViewById(R.id.adapter_array_listview);


        // TODO: 2016/6/1 构造数据源  arrays 
        String[] arrays = new String[]{"android","ios","java","j2ee","wphone","net","javascript","spring","structs","html","css","hibernate"};


        // TODO: 2016/6/1 实例适配器  adapter 
        ArrayAdapter adapter = new ArrayAdapter(this,R.layout.item_adapter_array_view,arrays);
//        ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,arrays);
        // TODO: 2016/6/1 设置adapter
        mListView.setAdapter(adapter);


    }
}

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:153次
    • 积分:50
    • 等级:
    • 排名:千里之外
    • 原创:5篇
    • 转载:0篇
    • 译文:0篇
    • 评论:0条
    文章存档