模擬新浪微博 隨便看看

2021-07-02 12:17:46 字數 1276 閱讀 4952

我們在使用android應用的時候,看到的listview效果經常也會看到和文字共存的情況。比如新狼微博中別人發布的訊息

有3個textview。用於顯示列表每一行的文字和

<?xml version="1.0" encoding="utf-8"?>

< linearlayout xmlns:android=""

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="horizontal" >

< /linearlayout>

然後用arrayadapter(context context, int textviewresourceid,listone) 

// 這個方法在每個子項被滾動到螢幕內的時候會被呼叫

// getview()方法中還有乙個convertview引數,這個引數用於將之前載入好的布局進行快取,以便之後可以進行重用

public view getview(int position, view convertview, viewgroup parent) else

viewholder.one1.setimageresource(one.getimageid());

viewholder.name.settext(one.getname());

viewholder.time.settext(one.gettime());

viewholder.one2.settext(one.getcontent());

return view;

}class viewholder

}

執行後的現實結構如下圖

然後,在mainactivity中通過get方法得到資料

public class mainactivity extends activity 

});} private void initone()

最後效果如下:

模擬新浪微博隨便看看欄目

使用listview來模仿微博隨便看看欄 分析 要完成這個效果,我們需要 1.listview及list itrm extends activity的編寫 2.定義資料集合 3.建立 adapter繫結資料 4.新增單擊事件 編碼 mainactivity package com.example.a...

模擬新浪微博隨便看看介面布局

布局 布局中標題欄的樣式是新建的乙個xml檔案 android layout width fill parent android layout height wrap content android orientation vertical android background d2691e 在主布...

模擬新浪微博

1.專案效果圖 主要 如下 android layout width match parent android layout height match parent android padding 10dip android orientation vertical 2 獲取xml資源 在andro...