开发者

How to add top item in list view?

Basically I want a list view(CheckBox and TextView) that has all the data from a database but the first item in the view always being "ALL".I have done loading listadapter but i don't know how to add first row as All. If I am clicking All checkebox.I want to other check开发者_运维问答box's state as false. my code as follow..


Why don't you do it like this?

You get position in getview(), then for the first item add condition. Something like this:

if(position == 0)


    youTextView.setText("All");

That's it.


you can add HeaderView in ListView

here is simple code of How to add HeaderView in ListView.

LayoutInflater inflater = getLayoutInflater();
LinearLayout listHeaderView = (LinearLayout)inflater.inflate(
                R.layout.headerview, null);
ListView.addHeaderView(listHeaderView);

create headerview.xml and you can add in this layout TextView with "ALL" text.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜