程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> JAVA編程 >> 關於JAVA >> java mail應用qq郵箱發郵件的設置裝備擺設辦法

java mail應用qq郵箱發郵件的設置裝備擺設辦法

編輯:關於JAVA

java mail應用qq郵箱發郵件的設置裝備擺設辦法。本站提示廣大學習愛好者:(java mail應用qq郵箱發郵件的設置裝備擺設辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是java mail應用qq郵箱發郵件的設置裝備擺設辦法正文


明天給年夜家講講android的目次完成辦法,就像年夜家看到的小說目次一樣,android 供給了ExpandableListView控件可以完成二級列表展現後果,如今給年夜家講講這個控件的用法,上面是XML界說:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="#FFFFFF"
  >
  <ExpandableListView
       android:id="@+id/elv_journal_catalog"
       android:layout_height="fill_parent"
       android:layout_width="fill_parent"
       android:cacheColorHint="#FFFFFF"
       />
</LinearLayout>

這代碼很簡略,和寫listView的辦法差不多,接上去是ExpandableListView在activity中的代碼:

 private ExpandableListView elv_journal_catalog;
    private List<List<Article>> childrenObj;
         private JournalCatalogListAdapter adapter;
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.journal_catalog);
        init();
        elv_journal_catalog.setGroupIndicator(null);
        elv_journal_catalog.setDivider(null);

        loadData();
    }

    private void init() {
        elv_journal_catalog = (ExpandableListView) findViewById(R.id.elv_journal_catalog);
        elv_journal_catalog.setOnChildClickListener(listener);
    }
    private void loadData() {
        Message msg = handler.obtainMessage();
        msg.what = 1;
        msg.sendToTarget();

        childrenObj = new ArrayList<List<Article>>();
        new Thread() {

            @Override
            public void run() {
                if (!isLoading) {
                    queryArticleList();
                } else {
                    queryArticleListFromSqlite();
                }
            }

        }.start();

        adapter = new JournalCatalogListAdapter(this, childrenObj);
        elv_journal_catalog.setAdapter(adapter);
    }

ExpandableListView展現數據的時刻默許是每一個模塊下的列表項是閉合狀況的,假如要完成初始化的時刻就睜開可以經由過程ExpandableListView.expandGroup(location)辦法來完成,並且每一個父級列表項右邊會湧現一個體系自帶的圖標,這個圖標是用來表現列表睜開和閉合的狀況的,假如不顯示或許要調換這個圖標可以用
ExpandableListView.setGroupIndicator(Drawable icon)辦法來完成,我這裡是直接是沒有應用任何圖標,你也能夠在adapter中本身在xml中界說本身的圖標.
ExpandableListView填湊數據須要是二級菜單的形式所以數據構造年夜家可以依據項目情形而定,我這裡因為題目是定逝世的所以只傳的每一個題目下的數據,上面是JournalCatalogListAdapter的代碼:


public class JournalCatalogListAdapter extends BaseExpandableListAdapter {

    private LayoutInflater inflater;

    private String[] parent = new String[] { "美顏美體", "潮水單品", "文娛八卦", "情緒",
            "不雅點", "安康生涯" };

    private List<List<Article>> clildren = new ArrayList<List<Article>>();

    public JournalCatalogListAdapter(Context context,
            List<List<Article>> clildren) {
        this.clildren = clildren;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return clildren.get(groupPosition).get(childPosition);
    }

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

    @Override
    public View getChildView(int groupPosition, int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(
                    R.layout.journal_catalog_list_item_content, null);
        }
        TextView textView = (TextView) convertView
                .findViewById(R.id.tv_journal_catalog_list_item_content);
        Article a = (Article) getChild(groupPosition, childPosition);
        textView.setText(a.getTitle());
        return convertView;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return clildren.get(groupPosition).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return parent[groupPosition];
    }

    @Override
    public int getGroupCount() {
        return parent.length;
    }

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(
                    R.layout.journal_catalog_list_item_title, null);
        }
        TextView textView = (TextView) convertView
                .findViewById(R.id.tv_journal_catalog_list_item_title);

        String title = String.valueOf(getGroup(groupPosition));
        textView.setText(title);
        convertView.setOnClickListener(null);
        return convertView;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

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

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved