Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement an Extensible header Control imitating QQ by Android

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Editor to share with you how to achieve Android imitating QQ stretchable head control, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The general idea of the control is:

1. Add the header view by inheriting listview. two。 Monitor listview scrolling. 3. Custom animation springback.

The layout of activity-main.xml is as follows:

Headerview.xml layout:

List_item layout:

"

Activity Code:

Package com.example.headerlistview;import java.util.ArrayList;import java.util.HashMap;import java.util.List;import java.util.Map;import android.os.Bundle;import android.app.Activity;import android.view.LayoutInflater;import android.view.Menu;import android.view.View;import android.widget.BaseAdapter;import android.widget.ImageView;import android.widget.ListView;import android.widget.SimpleAdapter;public class MainActivity extends Activity {private HeaderListView header_lv; private ImageView header_iv @ Override protected void onCreate (Bundle savedInstanceState) {super.onCreate (savedInstanceState); setContentView (R.layout.activity_main); getHeaderView (); initView ();} private void initView () {/ / TODO Auto-generated method stub header_lv= (HeaderListView) findViewById (R.id.header_lv); header_lv.addHeaderView (getHeaderView ()); header_lv.setHeaderView (header_iv); header_lv.setAdapter (getSimpleAdapter ());} public BaseAdapter getSimpleAdapter () {List data=new ArrayList (); for (int item0

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report