模拟新浪微博随便看看栏目

来源:互联网 发布:combox控件绑定数据库 编辑:程序博客网 时间:2024/05/16 17:48

1.package cn.edu.bzu.sinalook;

 

import java.util.ArrayList;

import java.util.List;

 

import android.app.Activity;

import android.os.Bundle;

import android.widget.ListView;

 

publicclass MainActivityextends Activity {

 

    private MyAdapteradapter;

    private ListViewlv;

    private List<ListCell>list;

    @Override

    protectedvoid onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

       setContentView(R.layout.activity_main);

      

       lv = (ListView) findViewById(R.id.lv);

 

       list =new ArrayList<ListCell>();

       //测试数据

       list.add(new ListCell(R.drawable.p1,"胖胖","2015-05-02","又要吃肉肉啦,真的好开心!"));

       list.add(new ListCell(R.drawable.p2,"飞飞","2015-05-02","好好学习"));

       list.add(new ListCell(R.drawable.p3,"亮亮","2015-05-02","好想谈恋爱呀"));

       list.add(new ListCell(R.drawable.p4,"辉辉","2015-05-02","游戏又要开始啦"));

       list.add(new ListCell(R.drawable.p5,"可可","2015-05-02","要开始学习了"));

       list.add(new ListCell(R.drawable.p6,"城城","2015-05-02","好无聊"));

      

       adapter=new MyAdapter(MainActivity.this,list);

      

       lv.setAdapter(adapter);

    }

 

}

 

 

 

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

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

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="horizontal"

    android:background="#EEEEEE">

 

    <ImageView

        android:id="@+id/ivIcon"

        android:layout_width="40dp"

        android:layout_height="40dp"

        android:layout_margin="3dp"

        android:contentDescription="@string/iv_des"/>

 

    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginLeft="10dp">

 

        <TextView

            android:id="@+id/tvName"

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_alignParentLeft="true"

            android:layout_alignParentTop="true"

            android:layout_marginTop="7dp"

            android:text="@string/tv_name"

            android:textAppearance="?android:attr/textAppearanceLarge"/>

 

 

 

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

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:background="@drawable/shan"

    android:layout_height="match_parent"

    android:orientation="vertical"

    tools:context=".MainActivity">

 

    <TextView

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:text="@string/tv_title"/>

 

    <ListView

        android:id="@+id/lv"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginTop="6dp">

    </ListView>

 

</LinearLayout>

 

 

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

<resources>

 

    <stringname="app_name">黄国城</string>

    <stringname="action_settings">Settings</string>

    <stringname="hello_world">Hello world!</string>

    <stringname="tv_title">新浪微博-随便看看栏目</string>

    <stringname="iv_des">用户图标</string>

    <stringname="tv_name">小城</string>

    <stringname="tv_time">2分钟前</string>

 

</resources>

0 0
原创粉丝点击