06.实例篇:仿QQ好友列表——ExpandableListView和ListView(下篇)

Python发送微信消息(文字、图片、文件)给指定好友和微信群(调用Win32 API模拟人的手动操作来发送消息) 本示例是调用Windows API模拟发送,用Python调用win32api这个库来调用Windows API模拟人的手动操作来发送消息。 在使用前,请将你微信的窗口设置为在最前面,这样就便于程序找到你的窗口! import pyautogui import time import win32api import win32con import win32gui import win32clipboard as w def FindWindow(chatroom): win = win 阅读详情

1.前言

本篇主要ExpandableListView和ListView一些基础知识点介绍,主要包括一些类和接口的使用介绍,主要是参照google 最新的API文档摘要总结的;


2.什么是ListView

是一种ViewGroup,用于滚动展示一组列表,这些列表项自动由Adapter从数据源读取数据产生特定的View填充到ListView;
当布局中的内容是动态的或者预先不可知的,可以使用AdapterView(ListView,GridView是其子类)运行时填充;
AdapterView(包括子类)使用Adapter绑定数据到自己,Adapter是数据源和AdapterView布局的中介;


3.ListView重要方法和属性:

  用于垂直滚动列表视图,列表项来自ListAdapter;
  类继承结构:具体的类
  public class  ListView  extends AbsListView 
    java.lang.Object
       ↳ android.view.View
         ↳ android.view.ViewGroup
           ↳ android.widget.AdapterView<T extends android.widget.Adapter>
                ↳ android.widget.AbsListView
                   ↳ android.widget.ListView
  直接子类:
        ExpandableListView :用于展示两级列表;
 
  重要的XML属性:
    android:divider:两个列表项之间的分割线(可以使color或者Drawable)
    android:dividerHeight:分割线的高度(厚度)
    android:entries:静态引用一个数组资源,用来填充ListView的
    android:footerDividersEnabled:对于footer view是否有divider
    android:headerDividersEnabled:
  从AbsListView继承的重要属性:
    android:choiceMode:设置列表项的选择行为,是否可以选择,是否支持多选
    android:listSelector :设置列表中被选中的项的Drawable
    android:textFilterEnabled:是否支持过滤


  重要方法:
      void  addFooterView(View v):添加固定的View到列表的底部,在setAdapter之前调用,可以添加多次,显示多个
      void addFooterView(View v, Object data, boolean isSelectable)      
      void addHeaderView(View v)
    
      ListAdapter getAdapter():返回与之绑定的Adapter
      void setAdapter (ListAdapter adapter) :设置ListView的数据

      long[] getCheckItemIds ():api8过期,获取选择的多个Items的id,仅当模式不是CHOICE_MODE_NONE.有效
      void setSelection (int position):设置选定的列表项,从0开始

4.ListView相关的类:ListAdapter(也是接口)

   public interface Adapter  android.widget.Adapter    
   间接子类:
   ArrayAdapter<T>, BaseAdapter, CursorAdapter, HeaderViewListAdapter, ListAdapter,    
   ResourceCursorAdapter, SimpleAdapter, SimpleCursorAdapter,SpinnerAdapter, WrapperListAdapter 
   方法:
   abstract int getCount():有多少数据
   abstract Object getItem(int position):获取特定位置的数据
   abstract long    getItemId(int position):获取特定位置的行id
   abstract View getView(int position, View convertView, ViewGroup parent):获取特定位置展示的View
   abstract boolean isEmpty():
  
   public interface ListAdapter implements Adapter (添加了两个抽象方法) android.widget.ListAdapter
   间接子类:
   ArrayAdapter<T>, BaseAdapter(抽象类), CursorAdapter(抽象类), HeaderViewListAdapter, 
   ResourceCursorAdapter, SimpleAdapter, SimpleCursorAdapter, WrapperListAdapter
     
   常用的Adapter:
   public class ArrayAdapter extends BaseAdapter implements Filterable:android.widget.ArrayAdapter<T>
   具体简单的Adapter类,数据源是数组,布局中有一个简单的TextView,如果想要其它View,可以重写getView方法
   使用一般重写,或者使用:
   public ArrayAdapter (Context context, int resource, T[] objects):Resource布局文件必须有特定名称的textview
   public ArrayAdapter (Context context, int resource, int textViewResourceId, T[] objects)
   public ArrayAdapter (Context context, int resource, List<T> objects)
   public ArrayAdapter (Context context, int resource, int textViewResourceId, List<T> objects)
    
   public class  SimpleCursorAdapter extends ResourceCursorAdapter:

   android.support.v4.widget.SimpleCursorAdapter

   构造器:
   SimpleCursorAdapter(Context context, int layout, Cursor c, String[] from, int[] to, int flags)
   参数:layout-定义列表项的布局文件,c-数据源cursor,可以为null(如果不可用),
             from-数组定义了需要绑定的cursor数据列名,to-表明view的id,用来展示数据
             flags-决定adapter的行为,FLAG_AUTO_REQUERY(过期,不建议使用,会在主线程中获取数据,阻塞)                   FLAG_REGISTER_CONTENT_OBSERVER
(添加内容监听器,当通知到来,

调用onContentChanged方法,小心内存泄露,当使用CursorAdapter[CursorLoader]时,不需要该标志;

   方法:
   Cursor swapCursor(Cursor c):换入一个新的Cursor,返回旧的cursor【未关闭】,如果cursor为null或者新的和旧的一样返回null
   public abstract class  CursorAdapter  extends BaseAdapter implements Filterable


5.ListView使用方式:【读取本地数据】

  •     需要ListView;
  •    需要ListAdapter及其子类;
  •    如果Adpater数据发生变化,应该调用notifyDataSetChanged()方法;
   ListView+ArrayAdapter方法:
   定制每一项文本内容,可以重写数组中每个对象的toString方法;
   定制ListView每一项的视图,可以重写getView方法;
   ArrayAdapter adapter = new ArrayAdapter<String>(this,
        android.R.layout.simple_list_item_1, myStringArray);
   ListView listView = (ListView) findViewById(R.id.listview);
   listView.setAdapter(adapter);

    ListView+SimpleCursorAdapter方法:
   String[] fromColumns = {ContactsContract.Data.DISPLAY_NAME,
                        ContactsContract.CommonDataKinds.Phone.NUMBER};
   int[] toViews = {R.id.display_name, R.id.phone_number};
   SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
        R.layout.person_name_and_number, cursor, fromColumns, toViews, 0);
   ListView listView = getListView();
   listView.setAdapter(adapter);

   处理点击事件:实现AdapterView.onItemClickListener接口
<pre name="code" class="java">    // Create a message handling object as an anonymous class.
    private OnItemClickListener mMessageClickedHandler = new OnItemClickListener() {
        public void onItemClick(AdapterView parent, View v, int position, long id) {
        // Do something in response to the click
        }
    };

    listView.setOnItemClickListener(mMessageClickedHandler); 
    
使用CursorLoader+ListView方法:   
  public class ListViewLoader extends ListActivity
        implements LoaderManager.LoaderCallbacks<Cursor> {


    // This is the Adapter being used to display the list's data
    SimpleCursorAdapter mAdapter;


    // These are the Contacts rows that we will retrieve
    static final String[] PROJECTION = new String[] {ContactsContract.Data._ID,
            ContactsContract.Data.DISPLAY_NAME};


    // This is the select criteria
    static final String SELECTION = "((" + 
            ContactsContract.Data.DISPLAY_NAME + " NOTNULL) AND (" +
            ContactsContract.Data.DISPLAY_NAME + " != '' ))";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        // Create a progress bar to display while the list loads
        ProgressBar progressBar = new ProgressBar(this);
        progressBar.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,
                LayoutParams.WRAP_CONTENT, Gravity.CENTER));
        progressBar.setIndeterminate(true);
        getListView().setEmptyView(progressBar);


        // Must add the progress bar to the root of the layout
        ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
        root.addView(progressBar);


        // For the cursor adapter, specify which columns go into which views
        String[] fromColumns = {ContactsContract.Data.DISPLAY_NAME};
        int[] toViews = {android.R.id.text1}; // The TextView in simple_list_item_1


        // Create an empty adapter we will use to display the loaded data.
        // We pass null for the cursor, then update it in onLoadFinished()
        mAdapter = new SimpleCursorAdapter(this, 
                android.R.layout.simple_list_item_1, null,
                fromColumns, toViews, 0);
        setListAdapter(mAdapter);


        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);
    }


    // Called when a new Loader needs to be created
    public Loader<Cursor> onCreateLoader(int id, Bundle args) {
        // Now create and return a CursorLoader that will take care of
        // creating a Cursor for the data being displayed.
        return new CursorLoader(this, ContactsContract.Data.CONTENT_URI,
                PROJECTION, SELECTION, null, null);
    }


    // Called when a previously created loader has finished loading
    public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
        // Swap the new cursor in.  (The framework will take care of closing the
        // old cursor once we return.)
        mAdapter.swapCursor(data);
    }


    // Called when a previously created loader is reset, making the data unavailable
    public void onLoaderReset(Loader<Cursor> loader) {
        // This is called when the last Cursor provided to onLoadFinished()
        // above is about to be closed.  We need to make sure we are no
        // longer using it.
        mAdapter.swapCursor(null);
    }


    @Override 
    public void onListItemClick(ListView l, View v, int position, long id) {
        // Do something when a list item is clicked
    }
}  

5.ListView动态获取网络数据方式【见下一节文章】

6.ExpandableListView相关类和知识点

   public class  ExpandableListView extends ListView:ListView的子类,android.widget.ExpandableListView
   两级列表,分为组和组中Items,使用ExpandableListAdapter接口提供数据;

   重要的接口:
   ExpandableListView.OnChildClickListener 、ExpandableListView.OnGroupClickListener
   ExpandableListView.OnGroupCollapseListener 、ExpandableListView.OnGroupExpandListener


   重要的XML属性:
   android:childDivider:color或者Drawable资源文件,子项目的分隔符
   android:childIndicator :状态列表的Drawable资源文件,用于定义子项目各种状态对应的效果
   android:groupIndicator 


   重要方法:
   ExpandableListAdapter getExpandableListAdapter():
   boolean collapseGroup(int groupPos)
   boolean expandGroup(int groupPos)
   boolean expandGroup(int groupPos, boolean animate)
   long getSelectedPosition():获取选择Group或者child的位置,该位置是打包以后的;综合的
   long getSelectedId ():获取已经选择的Group或者child的id,如果没选择,则返回-1;
   static int getPackedPositionChild(long packedPosition)  
   public boolean setSelectedChild (int groupPosition, int childPosition, boolean shouldExpandGroup)
   public void setSelectedGroup (int groupPosition)

   相关的类:public interface ExpandableListAdapter:按Group组织数据,为可展开类别提供数据;
   间接子类:
   BaseExpandableListAdapter, CursorTreeAdapter, ResourceCursorTreeAdapter, 
   SimpleCursorTreeAdapter, SimpleExpandableListAdapter
   
   SimpleExpandableListAdapter:

   注意groupTo和ChildTo所对应的视图都是TextView才行(ImageView不行,其它类型的视图,需要重写getGroupView和getChildView方法;);
       简单的Adapter映射静态数据到group和child view。
       构造器:9个参数

       SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, int groupLayout, 
                String[] groupFrom, int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData,
                 int childLayout, String[] childFrom, int[] childTo)
                 context:AdapterView运行环境上下文
                 groupData:Map的列表,列表中的每一项代表一组所有属性数据,Map包含组的数据,至少包含groupFrom所有的条目,例如每个Group需要一个textView和ImageView,那么可以map1.put("text","xxxx"); map1.put("image", "ddd")作为第一组的group Item;
                 groupLayout:Group视图的布局文件id,至少包含groupTo中的所有组件id
                 groupFrom:一组keys(用于获取每个组的数据,因为一个组项view可能需要多个数据),用于从Maps获取关联的该组view的数据
                 groupTo:一组view id,用于对应展示groupFrom中列数据
                 childData:Map对象列表的列表,外围的列表代表每个组,里面的列表代表每一组里面的项所有属性数据;

 其它参数类似;   

       SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData, 
                int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom,
                int[] groupTo, List<? extends List<? extends Map<String, ?>>> childData, 
                int childLayout, String[] childFrom, int[] childTo)


       SimpleExpandableListAdapter(Context context, List<? extends Map<String, ?>> groupData,
                int expandedGroupLayout, int collapsedGroupLayout, String[] groupFrom, int[] groupTo, 
                List<? extends List<? extends Map<String, ?>>> childData, int childLayout, 
                int lastChildLayout, String[] childFrom, int[] childTo)

        SimpleCursorTreeAdapter:
        
SimpleCursorTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout,
                 int expandedGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, 
                 int lastChildLayout, String[] childFrom, int[] childTo)


        SimpleCursorTreeAdapter(Context context, Cursor cursor, int collapsedGroupLayout, 
                int expandedGroupLayout, String[] groupFrom, int[] groupTo, int childLayout, 
                String[] childFrom, int[] childTo)


        SimpleCursorTreeAdapter(Context context, Cursor cursor, int groupLayout, String[] groupFrom,
                 int[] groupTo, int childLayout, String[] childFrom, int[] childTo)

7.ExpandableListView的使用实例

    参见上篇文章:http://blog.csdn.net/meplusplus/article/details/26622261

8.如何定制自己的ExpandableListAdapter

     主要是学习系统的源码实现,继承已有的ListAdapter,以下是系统SimpleExpandableListAdapter的源码实现,我们可以继承然后重写getChildView和getGroupView方法;
package android.widget;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.view.LayoutInflater;

import java.util.List;
import java.util.Map;

/**
 * An easy adapter to map static data to group and child views defined in an XML
 * file. You can separately specify the data backing the group as a List of
 * Maps. Each entry in the ArrayList corresponds to one group in the expandable
 * list. The Maps contain the data for each row. You also specify an XML file
 * that defines the views used to display a group, and a mapping from keys in
 * the Map to specific views. This process is similar for a child, except it is
 * one-level deeper so the data backing is specified as a List<List<Map>>,
 * where the first List corresponds to the group of the child, the second List
 * corresponds to the position of the child within the group, and finally the
 * Map holds the data for that particular child.
 */
public class SimpleExpandableListAdapter extends BaseExpandableListAdapter {
    private List<? extends Map<String, ?>> mGroupData;
    private int mExpandedGroupLayout;
    private int mCollapsedGroupLayout;
    private String[] mGroupFrom;
    private int[] mGroupTo;
    
    private List<? extends List<? extends Map<String, ?>>> mChildData;
    private int mChildLayout;
    private int mLastChildLayout;
    private String[] mChildFrom;
    private int[] mChildTo;
    
    private LayoutInflater mInflater;
    
    /**
     * Constructor
     * 
     * @param context The context where the {@link ExpandableListView}
     *            associated with this {@link SimpleExpandableListAdapter} is
     *            running
     * @param groupData A List of Maps. Each entry in the List corresponds to
     *            one group in the list. The Maps contain the data for each
     *            group, and should include all the entries specified in
     *            "groupFrom"
     * @param groupFrom A list of keys that will be fetched from the Map
     *            associated with each group.
     * @param groupTo The group views that should display column in the
     *            "groupFrom" parameter. These should all be TextViews. The
     *            first N views in this list are given the values of the first N
     *            columns in the groupFrom parameter.
     * @param groupLayout resource identifier of a view layout that defines the
     *            views for a group. The layout file should include at least
     *            those named views defined in "groupTo"
     * @param childData A List of List of Maps. Each entry in the outer List
     *            corresponds to a group (index by group position), each entry
     *            in the inner List corresponds to a child within the group
     *            (index by child position), and the Map corresponds to the data
     *            for a child (index by values in the childFrom array). The Map
     *            contains the data for each child, and should include all the
     *            entries specified in "childFrom"
     * @param childFrom A list of keys that will be fetched from the Map
     *            associated with each child.
     * @param childTo The child views that should display column in the
     *            "childFrom" parameter. These should all be TextViews. The
     *            first N views in this list are given the values of the first N
     *            columns in the childFrom parameter.
     * @param childLayout resource identifier of a view layout that defines the
     *            views for a child. The layout file should include at least
     *            those named views defined in "childTo"
     */
    public SimpleExpandableListAdapter(Context context,
            List<? extends Map<String, ?>> groupData, int groupLayout,
            String[] groupFrom, int[] groupTo,
            List<? extends List<? extends Map<String, ?>>> childData,
            int childLayout, String[] childFrom, int[] childTo) {
        this(context, groupData, groupLayout, groupLayout, groupFrom, groupTo, childData,
                childLayout, childLayout, childFrom, childTo);
    }

    /**
     * Constructor
     * 
     * @param context The context where the {@link ExpandableListView}
     *            associated with this {@link SimpleExpandableListAdapter} is
     *            running
     * @param groupData A List of Maps. Each entry in the List corresponds to
     *            one group in the list. The Maps contain the data for each
     *            group, and should include all the entries specified in
     *            "groupFrom"
     * @param groupFrom A list of keys that will be fetched from the Map
     *            associated with each group.
     * @param groupTo The group views that should display column in the
     *            "groupFrom" parameter. These should all be TextViews. The
     *            first N views in this list are given the values of the first N
     *            columns in the groupFrom parameter.
     * @param expandedGroupLayout resource identifier of a view layout that
     *            defines the views for an expanded group. The layout file
     *            should include at least those named views defined in "groupTo"
     * @param collapsedGroupLayout resource identifier of a view layout that
     *            defines the views for a collapsed group. The layout file
     *            should include at least those named views defined in "groupTo"
     * @param childData A List of List of Maps. Each entry in the outer List
     *            corresponds to a group (index by group position), each entry
     *            in the inner List corresponds to a child within the group
     *            (index by child position), and the Map corresponds to the data
     *            for a child (index by values in the childFrom array). The Map
     *            contains the data for each child, and should include all the
     *            entries specified in "childFrom"
     * @param childFrom A list of keys that will be fetched from the Map
     *            associated with each child.
     * @param childTo The child views that should display column in the
     *            "childFrom" parameter. These should all be TextViews. The
     *            first N views in this list are given the values of the first N
     *            columns in the childFrom parameter.
     * @param childLayout resource identifier of a view layout that defines the
     *            views for a child. The layout file should include at least
     *            those named views defined in "childTo"
     */
    public SimpleExpandableListAdapter(Context context,
            List<? extends Map<String, ?>> groupData, int expandedGroupLayout,
            int collapsedGroupLayout, String[] groupFrom, int[] groupTo,
            List<? extends List<? extends Map<String, ?>>> childData,
            int childLayout, String[] childFrom, int[] childTo) {
        this(context, groupData, expandedGroupLayout, collapsedGroupLayout,
                groupFrom, groupTo, childData, childLayout, childLayout,
                childFrom, childTo);
    }

    /**
     * Constructor
     * 
     * @param context The context where the {@link ExpandableListView}
     *            associated with this {@link SimpleExpandableListAdapter} is
     *            running
     * @param groupData A List of Maps. Each entry in the List corresponds to
     *            one group in the list. The Maps contain the data for each
     *            group, and should include all the entries specified in
     *            "groupFrom"
     * @param groupFrom A list of keys that will be fetched from the Map
     *            associated with each group.
     * @param groupTo The group views that should display column in the
     *            "groupFrom" parameter. These should all be TextViews. The
     *            first N views in this list are given the values of the first N
     *            columns in the groupFrom parameter.
     * @param expandedGroupLayout resource identifier of a view layout that
     *            defines the views for an expanded group. The layout file
     *            should include at least those named views defined in "groupTo"
     * @param collapsedGroupLayout resource identifier of a view layout that
     *            defines the views for a collapsed group. The layout file
     *            should include at least those named views defined in "groupTo"
     * @param childData A List of List of Maps. Each entry in the outer List
     *            corresponds to a group (index by group position), each entry
     *            in the inner List corresponds to a child within the group
     *            (index by child position), and the Map corresponds to the data
     *            for a child (index by values in the childFrom array). The Map
     *            contains the data for each child, and should include all the
     *            entries specified in "childFrom"
     * @param childFrom A list of keys that will be fetched from the Map
     *            associated with each child.
     * @param childTo The child views that should display column in the
     *            "childFrom" parameter. These should all be TextViews. The
     *            first N views in this list are given the values of the first N
     *            columns in the childFrom parameter.
     * @param childLayout resource identifier of a view layout that defines the
     *            views for a child (unless it is the last child within a group,
     *            in which case the lastChildLayout is used). The layout file
     *            should include at least those named views defined in "childTo"
     * @param lastChildLayout resource identifier of a view layout that defines
     *            the views for the last child within each group. The layout
     *            file should include at least those named views defined in
     *            "childTo"
     */
    public SimpleExpandableListAdapter(Context context,
            List<? extends Map<String, ?>> groupData, int expandedGroupLayout,
            int collapsedGroupLayout, String[] groupFrom, int[] groupTo,
            List<? extends List<? extends Map<String, ?>>> childData,
            int childLayout, int lastChildLayout, String[] childFrom,
            int[] childTo) {
        mGroupData = groupData;
        mExpandedGroupLayout = expandedGroupLayout;
        mCollapsedGroupLayout = collapsedGroupLayout;
        mGroupFrom = groupFrom;
        mGroupTo = groupTo;
        
        mChildData = childData;
        mChildLayout = childLayout;
        mLastChildLayout = lastChildLayout;
        mChildFrom = childFrom;
        mChildTo = childTo;
        
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    
    public Object getChild(int groupPosition, int childPosition) {
        return mChildData.get(groupPosition).get(childPosition);
    }

    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
            View convertView, ViewGroup parent) {
        View v;
        if (convertView == null) {
            v = newChildView(isLastChild, parent);
        } else {
            v = convertView;
        }
        bindView(v, mChildData.get(groupPosition).get(childPosition), mChildFrom, mChildTo);
        return v;
    }

    /**
     * Instantiates a new View for a child.
     * @param isLastChild Whether the child is the last child within its group.
     * @param parent The eventual parent of this new View.
     * @return A new child View
     */
    public View newChildView(boolean isLastChild, ViewGroup parent) {
        return mInflater.inflate((isLastChild) ? mLastChildLayout : mChildLayout, parent, false);
    }
    
    private void bindView(View view, Map<String, ?> data, String[] from, int[] to) {
        int len = to.length;

        for (int i = 0; i < len; i++) {
            TextView v = (TextView)view.findViewById(to[i]);
            if (v != null) {
                v.setText((String)data.get(from[i]));
            }
        }
    }

    public int getChildrenCount(int groupPosition) {
        return mChildData.get(groupPosition).size();
    }

    public Object getGroup(int groupPosition) {
        return mGroupData.get(groupPosition);
    }

    public int getGroupCount() {
        return mGroupData.size();
    }

    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
            ViewGroup parent) {
        View v;
        if (convertView == null) {
            v = newGroupView(isExpanded, parent);
        } else {
            v = convertView;
        }
        bindView(v, mGroupData.get(groupPosition), mGroupFrom, mGroupTo);
        return v;
    }

    /**
     * Instantiates a new View for a group.
     * @param isExpanded Whether the group is currently expanded.
     * @param parent The eventual parent of this new View.
     * @return A new group View
     */
    public View newGroupView(boolean isExpanded, ViewGroup parent) {
        return mInflater.inflate((isExpanded) ? mExpandedGroupLayout : mCollapsedGroupLayout,
                parent, false);
    }

    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    }

    public boolean hasStableIds() {
        return true;
    }

}


ListView+自定义Adapter实现简单的好友列表 android小白,用于总结自己学的知识。参考书目:郭霖《第一行代码》1.创建列表项布局        这里就简单的实现头像和名字的布局。    list_item.xml&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pa... 阅读详情

相关推荐

28.qt quick-ListView高仿微信好友列表和聊天列表

1.视图模型介绍 在Qml中、常见的View视图有: ListView: 列表视图,视图中数据来自ListModel、XmlListModel或c++中继承自QAbstractItemModel或QAbstractListModel的自定义模型类 TableView:和excel类似的视图 GridView: 网格视图,类似于home菜单那样,排列着一个个app小图标 PathView: ...

抵抗时间扭曲,坚持做一件有意义的事 3583

【微信自动化】使用c#实现微信自动化

本文由网友投稿作者:陈显达原文标题:【微信自动化】使用c#实现微信自动化原文链接:https://www.cnblogs.com/1996-Chinese-Chen/p/17663064.html引言上个月,在一个群里摸鱼划水空度日,看到了一个老哥分享的一个微信自动化的一个类库,便下载了他的Demo,其本意就是模拟鼠标来操作UI,实现UI自动化;然后自己在瞎琢磨研究,写了一个简单的例子,用来获取好...

zls365365的博客 1819

自定义列表控件仿QQ2010以后好友列表

主要功能: 1、重新自定义列表,实现列表标题栏和用户列表高度不一样自绘 2、满足原先要求的标题能展开和收起的情况下,给标题增加了用户列表的孩子节点个数显示 3、满足第二级菜单一张图和一串文字的情况下,增加另外一行最近消息的显示,第一行显示用户昵称 4、实现选中高亮紫色显示; 5、实现单选列表主题展开和收起 6、实现选中用户列表提示用户昵称信息 主要解决问题和bug: 1、自定义列表时Assert断言窗口失败; 2、自定义列表时主题和用户列表怎么分开显示; 3、自定义列表数据如何绑定,这个想了好久,也做了好多次实验,决定用映射数据的方式实现; 即addstring时只添加用户和列表的id,重绘时在列表数据结构中找到对应id信息; 4、解决用户展开和收起时图片错乱bug,建立图片列表和列别单项数据映射结构; 5、解决标题栏展开和收起用户列表显示错误bug; 6、解决标题栏和用户列表高度不一致的问题;

ExpandableListView的使用

ExpandableListView是ListView的子类,样式接近于QQ好友列表,今天写了个Demo,一起看看效果图 下面我们就来实现上图的这个效果:主要内容是ExAdapter继承BaseExpandableListAdapter,里面有两个比较重要方法getChildView(),getGroupView()。

beyond海阔天空 658

java实现的仿QQ好友列表

很多同志在用java做仿QQ聊天程序或者是做聊天程序时,都不自觉得想到了QQ好友列表,可是java中的JTree没有那个功能,又要显示头像又要显示昵称,这个资源不仅可以实现以上功能,而且可以显示个性签名和空间动态等,大家可以参考下,代码有详细的注释

扩展listview,仿QQ好友列表

这个demo是一个扩展的listview,仿QQ好友列表,可以添加人员,添加之后显示在对应的列表之下!

Android ListView好友列表展示

工程文件 https://download.csdn.net/download/qq_45688164/51976770 前端 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_.

qq_45688164的博客 2731

listbox 类似 qq好友列表实现

基于IconLBDemo修改,实现qq好友列表效果

andoird中仿QQ好友列表的ListVieW

andoird中仿QQ好友列表的ListVieW

qq_29586601的博客 725

java 高仿QQ8.x版本好友列表(socket聊天室项目)

高仿QQ8.x版本的好友界面,jdk版本1.8,正常1.6以上都可以直接运行,1.5版本应该改下泛型部分就可以正常运行。 主要是好友列表的界面效果,其它的部分没有细做,有需要的可以下载 预览图: (http://ouvjpvjng.bkt.clouddn.com/20170906134345_140050_clipboard.png) 作者:Scruel 转载请注明出处

C#自己绘制的QQ好友列表控件

详细介绍 看些的博客 http://blog.csdn.net/crystal_lz/article/details/8170491 顺便希望有人能解决一下博客中提到的TypeConverter的问题!、、

ListView实现自建Adapter和类似微信聊天好友列表

首先需要先建立两个xml文件,一个只有框架,另一个是对列表的详细布局。 第一个xml是: 第二个xml是: <ImageView android:id="@+id/iv_Image" android:layout_width="70dp" android:layout_height="90dp" android:src="@drawable/ifa" ...

Arex_Li的博客 899

保姆级教程:用Cadence Sigrity Power DC搞定HI3516A板卡电源压降仿真(含常见报错解决)

本文提供了一份详细的Cadence Sigrity Power DC直流压降仿真教程,特别针对HI3516A板卡设计。从环境准备、器件建模到仿真执行和结果解读,全面覆盖了电源完整性分析的关键步骤,并提供了常见报错的解决方案,帮助工程师快速掌握直流压降分析技术。

weixin_42569329的博客 338

android qq好友列表,Android入门(4)-ListView实现qq好友列表

摘要ListView是Android最常用的控件之一,也是最难用的控件之一,通过对于《第一行代码》的ListView教学,自主实现了一个模拟qq好友列表,这里进行记录并讲解首先ListView是一个列表类型的布局,其中包含着一项又一项的ListItem,例如这样:ListView图示但是,要注意的是,ListItem可不是那么容易就可以装入到ListView中的,就比如我们包装礼品的时候,我们需要...

weixin_30043767的博客 1072

完整指南:从基础到高级使用 Semantic Kernel

通过本文的学习,你已经掌握了从基础到高级的使用方法。安装并配置。使用简单的文本生成和自然语言处理任务。利用任务链和工具扩展构建复杂的工作流。通过记忆管理上下文,创建更智能的应用。扩展多模态处理能力,集成图像和音频分析。将应用部署到云端,并通过 Azure Functions 提供智能服务。无论是构建简单的对话应用,还是创建多模态智能服务,都提供了强大的工具和灵活的扩展机制。希望这篇文章能帮助你更好地理解并运用这个框架,构建出更加智能和高效的应用。

net core ,前端 ,python 全栈开发 2818

(超详细)Scala环境搭建(scala-2.12.15、IDEA2021.1.3)

Scala环境搭建(scala-2.12.15、IDEA2021.1.3) JunLeon——go big or go home 目录 Scala环境搭建(scala-2.12.15、IDEA2021.1.3) 一、Scala概述 1、什么是Scala? 2、Scala发展史 3、Scala与Java的关系 二、Scala环境搭建 1、环境准备 2、Scala安装与配置环境变量 3、验证Scala 三、编写第一个Scala程序 1、使用IDEA创建maven工程 2、.

JunLeon的博客 3万+

android:listview实现qq,微信好友列表(头像,昵称,个性签名)

首先附上运行结果: 如果你没有学过listview请你先看一看基本知识。不想再说的那么细了 太多了。 首先是listview布局 <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/lv_view" android:layout_width="ma

苏苏爱自由 9569

Vector CANape的使用记录

开门见山,今天想和大家分享下CANape使用记录,分享原因是近日在分析一个客户现场软件问题时,需要用到CANape来实时的监测ECU中的变量,因为之前对CANape的认知比较浅薄,觉得标定工程师使用他就足够了,但是这次的经历让我觉得需要写点东西来记录自己学习并使用他的过程。 相信大家能够在网上找到很多关于如何使用CANape的文章,从新建Project到后面的数据的观测、保存以及回放等等。我个人也是这么学过来的,所以我不打算从那些方面着手去描述如何使用她,而是根据我的真实使用过程以及问题的抛出到如何解决来

2万+

安卓:ListView组件实现微信通讯录效果(我的王者队友们)

ListView控件是列表视图展示,排列方式是纵向。 ListView组件实现微信通讯录效果,包含头像和文字,不能用entries这个属性来添加,要用SimpleAdapter适配器来添加数据布局:垂直线性布局方式 头和尾全部用 ImageView组件来实现,中间我们用 ListView。 效果如图:(可滑动,点击显示名字) 一、准备头像图片:大小建议80x80;top与bottom图片如下图,放入drawable; 二、在activity_main.xml建立组件,如图 ...

AZLAWW的博客 3484

Excel下拉公式不自动计算?5步彻底解决!

Excel下拉公式不自动计算?5步彻底解决!在使用Excel处理数据时,公式下拉填充是提升效率的核心操作。但许多用户都遇到过这样的困惑:明明设置了公式,下拉时结果却纹丝不动。本文将从技术原理出发,结合5步实操方案,为您彻底解析这个高频问题的根源与解决方案。

mmoo_python的博客 1万+

LLM Wiki 的完整输入体系:LLM Wiki极简实战

LLM Wiki 的输入分为**四大类**,覆盖从"原始知识注入"到"系统行为控制"的全流程,所有输入都遵循"**原始资料不可变,规则可迭代,人类反馈闭环**"的核心原则。

ZhangJiqun&191cm&85kg 346

android 好友功能,Android中使用ListView模拟微信好友功能

效果图:分析:1、创建listview2、创建数据3、创建适配器将数据放到呈现数据的容器里面。将这个容器(带数据)连接适配器。其实是直接在我们自己写的adapter的getview重载方法中返回连接的view。view view=view.inflate(mcontext, com.example.wechatfriends.r.layout.item_friend, null);return v...

weixin_33182798的博客 467

基于咸鱼最新九宫格图标验证码的语义增强模型识别

本文探讨了破解复杂验证码的技术思路,重点分析了某平台的九宫格验证码应对策略。作者提出通过图像语义抽取和增强技术来扩充数据集:先采集少量真实样本,利用形态学操作进行前增强生成变形图像,再通过叠加背景噪声进行后增强。同时强调真实数据集的重要性,建议采用真实+生成数据的混合训练方法。实验表明该方法可使模型准确率达到95%以上,但作者特别声明本文仅供技术研究,严禁用于非法用途。

码王吴彦祖的博客 610

android 好友功能,ListView模拟微信好友功能

[导读]ListView模拟微信好友功能效果图ListView模拟微信好友功能效果图:分析:1、创建listView2、创建数据3、创建适配器将数据放到呈现数据的容器里面。将这个容器(带数据)连接适配器。其实是直接在我们自己写的adapter的getView重载方法中返回连接的view。View view=View.inflate(mContext, com.example.weChatFrien...

weixin_29239661的博客 339

深度解析:Android开发工程师(嵌入式系统方向)职位 - 技术需求、面试准备与发展路径

本文深入分析了嵌入式Android开发工程师的岗位要求和技术内涵。该职位需要掌握C/C++、Linux系统编程、硬件接口等核心技术,能够进行Android系统底层定制开发,包括HAL层实现、Framework修改、性能优化等工作。文章详细解读了岗位职责,梳理了必备技术栈,提供了针对性的面试问题与参考答案,并探讨了职业发展路径。这类岗位要求开发者兼具软件工程能力和硬件基础知识,适合在智能电视、机顶盒、车载系统等嵌入式领域发展的技术人员。

郑伟强dev的专栏 144

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

扩展的ListView实例

今天从网上看了个扩展的listView的例子,感觉还蛮炫,自己也试着做了下。 由于比较简单,所有就直接上代码: public class ExtendedListView extends ExpandableListAc...

chenqunan3231的博客 154

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

上一篇: 05.实例篇:仿QQ好友列表——ExpandableListView可扩展列表的使用(上篇)
下一篇: 07.实例篇:ListView简单分页加载-ListView从网络分页加载数据
壹零Boy
博客等级 码龄14年 31粉丝 43原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址