zoukankan      html  css  js  c++  java
  • ListView(二)

    head.xml布局文件代码:

    <?xmlversion="1.0"encoding="utf-8"?>

    <TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="35px"  android:stretchColumns="0,1,2">

    <TableRow>

     <TextViewandroid:layout_width="fill_parent" 

        android:layout_height="35px"android:text="NAME"/>

    <TextViewandroid:layout_width="fill_parent"

        android:layout_height="35px"android:text="SEX"/>

    <TextViewandroid:layout_width="fill_parent"

        android:layout_height="35px"android:text="AGE"/>

     </TableRow>

    </TableLayout>

    Item布局文件代码:

    <?xmlversion="1.0"encoding="utf-8"?>

    <TableLayoutxmlns:android="http://schemas.android.com/apk/res/android"

        android:orientation="horizontal"

        android:layout_width="fill_parent"

        android:layout_height="35px"  android:stretchColumns="0,1,2">

    <TableRow>

     <TextViewandroid:layout_width="fill_parent" 

        android:layout_height="35px"android:id="@+id/name"/>

    <TextViewandroid:layout_width="fill_parent"

        android:layout_height="35px"android:id="@+id/sex"/>

    <TextViewandroid:layout_width="fill_parent"

        android:layout_height="35px"android:id="@+id/age"/>

     </TableRow>

    </TableLayout>

    Activity中的监听器代码:

    @Override

        protected void onListItemClick(ListView l, View v, int position, long id) {

           // TODO Auto-generated method stub

           HashMap<String,String> item=(HashMap<String,String>)(mItems.get(position-1));

           String info=item.get(mCloumns[0]).toString()+"    "+item.get(mCloumns[1]).toString()+

                  item.get(mCloumns[2]).toString();

           Toast.makeText(ListViewDemo.this, info, Toast.LENGTH_LONG).show();

           super.onListItemClick(l, v, position, id);

        }

  • 相关阅读:
    单档作业(带明细档)——项次自动自增
    单档——PK单号新增、修改时不允许编辑,PK单号自动生成
    单档——控件关联查询
    报表查询——自动刷新数据,双击明细打开关联作业
    asp.net练习②——Paginaton无刷新分页
    strcpy 用法
    2008年“超搞”语录
    IT职场里的某些人感悟(欢迎各抒己见)
    SQL2005无法正常登录
    经典短文
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429530.html
Copyright © 2011-2022 走看看