當前位置: 首頁>>代碼示例>>Java>>正文


Java ListView.addHeaderView方法代碼示例

本文整理匯總了Java中android.widget.ListView.addHeaderView方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.addHeaderView方法的具體用法?Java ListView.addHeaderView怎麽用?Java ListView.addHeaderView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ListView的用法示例。


在下文中一共展示了ListView.addHeaderView方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doShortcut

import android.widget.ListView; //導入方法依賴的package包/類
public void doShortcut() {

        setContentView(R.layout.activity_setup_widget);
        setupAppBar(R.id.toolbar, R.string.widget_creation_title, true, true);
        header = getLayoutInflater().inflate(R.layout.widget_header, null);

        ListView list = (ListView) findViewById(R.id.subs);
        final ArrayList<FeedWrapper> sorted = new ArrayList<FeedWrapper>(Realm.getDefaultInstance().where(Feed.class).findAllSorted("order"));
        sorted.addAll(Realm.getDefaultInstance().where(Category.class).findAllSorted("order"));
        Collections.sort(sorted, new Comparator<FeedWrapper>() {
            @Override
            public int compare(FeedWrapper p1, FeedWrapper p2) {
                return p1.getOrder() - p2.getOrder();// Ascending
            }

        });
        final SideArrayAdapter adapter = new SideArrayAdapter(this, sorted, list);

        list.addHeaderView(header);
        list.setAdapter(adapter);
    }
 
開發者ID:ccrama,項目名稱:Slide-RSS,代碼行數:22,代碼來源:SetupWidget.java

示例2: initializeHeaderAndFooter

import android.widget.ListView; //導入方法依賴的package包/類
private void initializeHeaderAndFooter() {
    setListAdapter(null);
    if (hasHeaderAndFooter) {
        ListView list = getListView();

        LayoutInflater inflater = LayoutInflater.from(this);
        TextView header1 = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, list, false);
        header1.setText("First header");
        list.addHeaderView(header1);

        TextView header2 = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, list, false);
        header2.setText("Second header");
        list.addHeaderView(header2);

        TextView footer = (TextView) inflater.inflate(android.R.layout.simple_list_item_1, list, false);
        footer.setText("Single footer");
        list.addFooterView(footer);
    }
    initializeAdapter();
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:PinnedSectionListActivity.java

示例3: onCreateView

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_settings, container, false);

    // Inflate chess.com logo
    View header = inflater.inflate(R.layout.list_settings_header, null);
    header.setOnClickListener(mHeaderClickListener);

    // Init ListView
    mListView = (ListView) v.findViewById(R.id.list_time_controls);
    mListView.addHeaderView(header, null, false);
    mListView.setOnItemClickListener(mItemClickListener);

    // Set start button listener
    mStartBtn = v.findViewById(R.id.btn_start);
    mStartBtn.setOnClickListener(mStartBtnListener);

    // Set List Adapter and selection positions.
    setupListView(savedInstanceState);

    return v;
}
 
開發者ID:ChessCom,項目名稱:android-chessclock,代碼行數:23,代碼來源:SettingsFragment.java

示例4: viewInitialize

import android.widget.ListView; //導入方法依賴的package包/類
public void viewInitialize()
{
    mainListView = (ListView) v.findViewById(R.id.listview);
    swiperefresh = (SwipeRefreshLayout) v.findViewById(R.id.swiperefresh);
    swiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()
    {
        @Override
        public void onRefresh()
        {
            prepare();
        }
    });

    cardHeader = new CardHeader(getContext());
    cardHeader.setTitleIcon(getResources().getDrawable(R.drawable.ic_thumb_up));
    cardHeader.setTitleText("가장 많이 들은 곡 20곡");
    mainListView.addHeaderView(cardHeader);
}
 
開發者ID:icaynia,項目名稱:pracler,代碼行數:19,代碼來源:MyTop20Fragment.java

示例5: initWidgets

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void initWidgets() {
    super.initWidgets();
    mLayoutBottom = (RelativeLayout) findViewById(R.id.kf5_bottom_layout);
    mFeedBackDetailBottomView = new FeedBackDetailBottomView(mActivity);
    mFeedBackDetailBottomView.setListener(this);
    mETContent = layoutListener.getEditText();
    mLayoutBottom.addView(mFeedBackDetailBottomView);
    mListView = (ListView) findViewById(R.id.kf5_activity_feed_back_details_listview);
    mListView.setOnScrollListener(this);
    mListView.setOnItemLongClickListener(this);
    mListView.addHeaderView(inflateHeaderView());
    mBackImg = (ImageView) findViewById(R.id.kf5_return_img);
    mBackImg.setOnClickListener(this);
    mRightView = (TextView) findViewById(R.id.kf5_right_text_view);
    mRightView.setOnClickListener(this);
}
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:18,代碼來源:FeedBackDetailsActivity.java

示例6: onCreate

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("info", "fragmentwefef");
    setContentView(R.layout.activity_info1_listview);
    topView= (LinearLayout) getLayoutInflater()
            .inflate(R.layout.activity_info1_headview, null);
    handler=new Handler();
    listView= (ListView) findViewById(R.id.info1_listView);
    listView.addHeaderView(topView);
    apps=new ArrayList<Data.App_Share_List>();
    bitmapUtils=new BitmapUtils(this);
    adapter=new Info1_ListViewAdapter(apps,this,bitmapUtils);
    listView.setAdapter(adapter);
    memberShareTagId=getIntent().getIntExtra("memberShareTagId", 0);
    path=String.format(method,memberShareTagId);
    httpUtils=new HttpUtils();

    //initHeadView(topView,mem);
    loadData();
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:22,代碼來源:Info1Activity.java

示例7: onCreate

import android.widget.ListView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_listview);

    mAutoScrollPagerAdapter = new BannerAdapter(this, 3, true);
    mListView = (ListView) findViewById(R.id.listview);
    mSwipeRefreshLayout = (CustomSwipeRefreshLayout) findViewById(R.id.swiperefresh_layout);
    // AutoScrollViewPager header
    View headerView = LayoutInflater.from(this).inflate(R.layout.list_header, mListView, false);
    mAutoScrollViewPager = (CycleViewPager) headerView.findViewById(R.id.banner);
    mIndicator = (ViewPagerIndicator) headerView.findViewById(R.id.viewpager_indicator);
    mListView.addHeaderView(headerView);
    // mAutoScrollViewPager.setPageSwitchDuration(800);
    // mAutoScrollViewPager.setAutoScrollInterval(4000);
    mListView.setAdapter(new ArrayAdapter<String>(WorkInListViewActivity.this, android.R.layout.simple_list_item_1, android.R.id.text1, getData()));
    mAutoScrollViewPager.setAdapter(mAutoScrollPagerAdapter);
    mIndicator.bindToViewPager(mAutoScrollViewPager);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            WorkInListViewActivity.this.onRefresh();
        }
    });
}
 
開發者ID:leandom,項目名稱:CycleViewPager,代碼行數:26,代碼來源:WorkInListViewActivity.java

示例8: setupViews

import android.widget.ListView; //導入方法依賴的package包/類
@Override
void setupViews(ViewGroup view) {
    if (showSearchBox) {
        ListView listView = (ListView) view.findViewById(R.id.com_facebook_picker_list_view);

        View searchHeaderView = getActivity().getLayoutInflater().inflate(
                R.layout.com_facebook_picker_search_box, listView, false);

        listView.addHeaderView(searchHeaderView, null, false);

        searchBox = (EditText) view.findViewById(R.id.com_facebook_picker_search_text);

        searchBox.addTextChangedListener(new SearchTextWatcher());
        if (!TextUtils.isEmpty(searchText)) {
            searchBox.setText(searchText);
        }
    }
}
 
開發者ID:MobileDev418,項目名稱:AndroidBackendlessChat,代碼行數:19,代碼來源:PlacePickerFragment.java

示例9: initView

import android.widget.ListView; //導入方法依賴的package包/類
private void initView() {
    // 獲取listview對象
    lv_grouplist = (ListView)findViewById(R.id.lv_grouplist);

    // 添加頭布局
    View headerView = View.inflate(this, R.layout.header_grouplist, null);
    lv_grouplist.addHeaderView(headerView);

    ll_grouplist = (LinearLayout) headerView.findViewById(R.id.ll_grouplist);
}
 
開發者ID:turoDog,項目名稱:KTalk,代碼行數:11,代碼來源:GroupListActivity.java

示例10: onActivityCreated

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    lAdapter = new LabelAdapter(getActivity(), null, 0);
    setListAdapter(lAdapter);
    getActivity().getSupportLoaderManager().initLoader(LOADER_ID, null, this);
    myActivity = (MainActivity) getActivity();
    myActivity.getSupportActionBar().setTitle("Labels");
    myActivity.hideSoftKeyboard(true);
    myActivity.fabVisibility(false);

    ListView listView = getListView();

    if(selecting){
        setActivateOnItemClick(true);
        myActivity.getSupportActionBar().setTitle("Select label");
        // Add "no label" to list
        View noLabel =  View.inflate(getContext(), R.layout.fragment_label_item, null);
        TextView labelTag = noLabel.findViewById(R.id.label_tag);
        labelTag.setText(R.string.none);
        listView.addHeaderView(noLabel);
    } else {
        listView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
        listView.setMultiChoiceModeListener(myMultiChoiceModeListener);
        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                ToduleLabelAddFragment f = ToduleLabelAddFragment.newInstance(l);
                myActivity.getSupportFragmentManager().beginTransaction()
                        .setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left, R.anim.enter_from_left, R.anim.exit_to_right)
                        .replace(R.id.fragment_container, f)
                        .addToBackStack(null)
                        .commit();
            }
        });
    }
}
 
開發者ID:danlls,項目名稱:Todule-android,代碼行數:38,代碼來源:ToduleLabelFragment.java

示例11: setListHeader

import android.widget.ListView; //導入方法依賴的package包/類
private void setListHeader(ListView listView) {
    ViewGroup header = (ViewGroup) getLayoutInflater().inflate(
            R.layout.view_task_create, listView, false);

    final ImageView imageView = (ImageView) header.findViewById(R.id.image);
    imageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            displayAttachImageDialog(null);
        }
    });

    final EditText text = (EditText) header.findViewById(R.id.text);
    text.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View view, int i, KeyEvent keyEvent) {
            if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) &&
                    (keyEvent.getKeyCode() == KeyEvent.KEYCODE_ENTER)) {
                String inputText = text.getText().toString();
                if (inputText.length() > 0)
                    createTask(inputText, mImageToBeAttached, mListId);

                text.setText("");
                deleteCurrentPhoto();

                return true;
            }
            return false;
        }
    });

    listView.addHeaderView(header);
}
 
開發者ID:Kaufland,項目名稱:andcouchbaseentity,代碼行數:34,代碼來源:TaskActivity.java

示例12: onCreate

import android.widget.ListView; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    setContentView(R.layout.barrage_list);
    ListView listView = getListView();
    LayoutInflater inflater = LayoutInflater.from(this);
    BarrageHeaderView headerView = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    headerView.bind(getString(R.string.menu_new_barrage), getString(R.string.create_new_barrage));
    listView.addHeaderView(headerView, null, true);
    
    //UI Preview
    /*BarrageHeaderView item1 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item1.bind(this, new BarrageHeader("Testing 1, 2, 3...", BarrageHeader.STATUS_RUNNING, 43, 12));
    listView.addHeaderView(item1, null, true);
    BarrageHeaderView item4 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item4.bind(this, new BarrageHeader("Another Barrage", BarrageHeader.STATUS_PAUSED, 123, 64));
    listView.addHeaderView(item4, null, true);
    BarrageHeaderView item2 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item2.bind(this, new BarrageHeader("Pie Day", BarrageHeader.STATUS_QUEUED, 43, 12));
    listView.addHeaderView(item2, null, true);
    BarrageHeaderView item3 = (BarrageHeaderView)inflater.inflate(R.layout.barrage_header_view, listView, false);
    item3.bind(this, new BarrageHeader("Some Name", BarrageHeader.STATUS_DRAFT, 160, 12));
    listView.addHeaderView(item3, null, true);*/
    
    setListAdapter(new BarrageListAdapter(this, null, true));
    
    if (savedInstanceState != null) {
    	//do something
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:32,代碼來源:BarrageList.java

示例13: initView

import android.widget.ListView; //導入方法依賴的package包/類
private void initView(View view) {
    mSearchEditText = (EditText) view.findViewById(R.id.search);
    mListView = (ListView) view.findViewById(R.id.listview);
    mNoFriends = (TextView) view.findViewById(R.id.show_no_friend);
    mSidBar = (SideBar) view.findViewById(R.id.sidrbar);
    mDialogTextView = (TextView) view.findViewById(R.id.group_dialog);
    mSidBar.setTextView(mDialogTextView);
    LayoutInflater mLayoutInflater = LayoutInflater.from(getActivity());
    mHeadView = mLayoutInflater.inflate(R.layout.item_contact_list_header,
                                        null);
    mUnreadTextView = (TextView) mHeadView.findViewById(R.id.tv_unread);
    RelativeLayout newFriendsLayout = (RelativeLayout) mHeadView.findViewById(R.id.re_newfriends);
    RelativeLayout groupLayout = (RelativeLayout) mHeadView.findViewById(R.id.re_chatroom);
    RelativeLayout publicServiceLayout = (RelativeLayout) mHeadView.findViewById(R.id.publicservice);
    RelativeLayout selfLayout = (RelativeLayout) mHeadView.findViewById(R.id.contact_me_item);
    mSelectableRoundedImageView = (SelectableRoundedImageView) mHeadView.findViewById(R.id.contact_me_img);
    mNameTextView = (TextView) mHeadView.findViewById(R.id.contact_me_name);
    updatePersonalUI();
    mListView.addHeaderView(mHeadView);
    mNoFriends.setVisibility(View.VISIBLE);

    selfLayout.setOnClickListener(this);
    groupLayout.setOnClickListener(this);
    newFriendsLayout.setOnClickListener(this);
    publicServiceLayout.setOnClickListener(this);
    //設置右側觸摸監聽
    mSidBar.setOnTouchingLetterChangedListener(new SideBar.OnTouchingLetterChangedListener() {

        @Override
        public void onTouchingLetterChanged(String s) {
            //該字母首次出現的位置
            int position = mFriendListAdapter.getPositionForSection(s.charAt(0));
            if (position != -1) {
                mListView.setSelection(position);
            }

        }
    });
}
 
開發者ID:zqHero,項目名稱:rongyunDemo,代碼行數:40,代碼來源:ContactsFragment.java

示例14: onActivityCreated

import android.widget.ListView; //導入方法依賴的package包/類
@Override 
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();

    //getListView().setSelector(R.drawable.transparent);
    lv.setCacheColorHint(Color.TRANSPARENT);
    
    
    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
    

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckFilterId = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if(mAdapter == null) {
        if(mHeaderView != null) {
            lv.addHeaderView(mHeaderView , null, true);
        }
        mAdapter = new AccountFiltersListAdapter(getActivity(), null);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        
        lv.setVerticalFadingEdgeEnabled(true);
    }
    
    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
    	Log.d("lp", "dual pane mode");
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    	//lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        lv.setVerticalScrollBarEnabled(false);
        lv.setFadingEdgeLength(50);
        
        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    }else {
    	//getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    	lv.setVerticalScrollBarEnabled(true);
    	lv.setFadingEdgeLength(100);
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:52,代碼來源:AccountFiltersListFragment.java

示例15: buildViews

import android.widget.ListView; //導入方法依賴的package包/類
private View buildViews() {
    View wrapperView = View.inflate(mContext, getContentViewLayoutId(), null);
    mTitleTv = (TextView) wrapperView.findViewById(R.id.title);
    mContainerView = (ListView) wrapperView.findViewById(R.id.listview);
    if (mTitle != null && mTitle.length() != 0) {
        mTitleTv.setVisibility(View.VISIBLE);
        mTitleTv.setText(mTitle);
    } else {
        mTitleTv.setVisibility(View.GONE);
    }
    if (mHeaderViews.size() > 0) {
        for (View headerView : mHeaderViews) {
            mContainerView.addHeaderView(headerView);
        }
    }
    if (needToScroll()) {
        mContainerView.getLayoutParams().height = getListMaxHeight();
        mDialog.setOnBottomSheetShowListener(new OnBottomSheetShowListener() {
            @Override
            public void onShow() {
                mContainerView.setSelection(mCheckedIndex);
            }
        });
    }

    mAdapter = new ListAdapter();
    mContainerView.setAdapter(mAdapter);
    return wrapperView;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:30,代碼來源:QMUIBottomSheet.java


注:本文中的android.widget.ListView.addHeaderView方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。