Java Code Examples for android.widget.ListView.addHeaderView()

The following are Jave code examples for showing how to use addHeaderView() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Slide-RSS   File: SetupWidget.java   View Source Code Vote up 7 votes
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);
    }
 
Example 2
Project: GitHub   File: PinnedSectionListActivity.java   View Source Code Vote up 6 votes
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();
}
 
Example 3
Project: android-chessclock   File: SettingsFragment.java   View Source Code Vote up 6 votes
@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;
}
 
Example 4
Project: pracler   File: MyTop20Fragment.java   View Source Code Vote up 6 votes
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);
}
 
Example 5
Project: yyox   File: FeedBackDetailsActivity.java   View Source Code Vote up 6 votes
@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);
}
 
Example 6
Project: ywApplication   File: Info1Activity.java   View Source Code Vote up 6 votes
@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();
}
 
Example 7
Project: CycleViewPager   File: WorkInListViewActivity.java   View Source Code Vote up 6 votes
@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();
        }
    });
}
 
Example 8
Project: AndroidBackendlessChat   File: PlacePickerFragment.java   View Source Code Vote up 6 votes
@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);
        }
    }
}
 
Example 9
Project: KTalk   File: GroupListActivity.java   View Source Code Vote up 5 votes
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);
}
 
Example 10
Project: Todule-android   File: ToduleLabelFragment.java   View Source Code Vote up 5 votes
@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();
            }
        });
    }
}
 
Example 11
Project: andcouchbaseentity   File: TaskActivity.java   View Source Code Vote up 5 votes
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);
}
 
Example 12
Project: buildAPKsApps   File: BarrageList.java   View Source Code Vote up 5 votes
@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
    }
}
 
Example 13
Project: rongyunDemo   File: ContactsFragment.java   View Source Code Vote up 5 votes
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);
            }

        }
    });
}
 
Example 14
Project: CSipSimple   File: AccountFiltersListFragment.java   View Source Code Vote up 5 votes
@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);
    }
}
 
Example 15
Project: qmui   File: QMUIBottomSheet.java   View Source Code Vote up 5 votes
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;
}
 
Example 16
Project: WordLing   File: SessionSummaryActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_session_summary);
    overridePendingTransition(R.anim.slide_in, R.anim.slide_out);

    // Get ListView
    ListView listView = (ListView) findViewById(R.id.list);
    // Get manager
    manager = (SortedSessionManager) getIntent().getSerializableExtra("SortedSessionManager");

    // .subList gets list without repeated words
    List editedList = manager.getWordpack().pack.subList(0, manager.getWordCount());

    // Set title - name of wordpack
    setTitle(manager.getWordpack().getTitle());

    LinearLayout header = (LinearLayout) getLayoutInflater().inflate(R.layout.activity_session_summary_header, null, false);
    ((TextView) header.findViewById(R.id.result)).setText(getResources().getString(R.string.result));

    TextView tv = (TextView) header.findViewById(R.id.percentText);
    Log.v("ASD", Integer.toString(manager.getPassedCount()));
    int percentRate = (manager.getPassedCount() * 100) / manager.getWordCount();
    tv.setText(Integer.toString(percentRate)+"%");

    // Set header view to list
    listView.addHeaderView(header, null, false);

    // Add empty space at beggining, used for headers
    editedList.add(0, null);
    SummaryListAdapter adapter = new SummaryListAdapter(this, editedList);
    listView.setAdapter(adapter);
}
 
Example 17
Project: weex-3d-map   File: SearchBookContentsActivity.java   View Source Code Vote up 5 votes
@Override
public void onCreate(Bundle icicle) {
  super.onCreate(icicle);

  // Make sure that expired cookies are removed on launch.
  CookieSyncManager.createInstance(this);
  CookieManager.getInstance().removeExpiredCookie();

  Intent intent = getIntent();
  if (intent == null || !intent.getAction().equals(Intents.SearchBookContents.ACTION)) {
    finish();
    return;
  }

  isbn = intent.getStringExtra(Intents.SearchBookContents.ISBN);
  if (LocaleManager.isBookSearchUrl(isbn)) {
    setTitle(getString(R.string.sbc_name));
  } else {
    setTitle(getString(R.string.sbc_name) + ": ISBN " + isbn);
  }

  setContentView(R.layout.search_book_contents);
  queryTextView = (EditText) findViewById(R.id.query_text_view);

  String initialQuery = intent.getStringExtra(Intents.SearchBookContents.QUERY);
  if (initialQuery != null && !initialQuery.isEmpty()) {
    // Populate the search box but don't trigger the search
    queryTextView.setText(initialQuery);
  }
  queryTextView.setOnKeyListener(keyListener);

  queryButton = findViewById(R.id.query_button);
  queryButton.setOnClickListener(buttonListener);

  resultListView = (ListView) findViewById(R.id.result_list_view);
  LayoutInflater factory = LayoutInflater.from(this);
  headerView = (TextView) factory.inflate(R.layout.search_book_contents_header,
      resultListView, false);
  resultListView.addHeaderView(headerView);
}
 
Example 18
Project: OpenEyesReading-android   File: BannerView.java   View Source Code Vote up 5 votes
@Override
protected void getView(List<String> list, ListView listView) {
    View view = mInflate.inflate(R.layout.view_banner, listView, false);
    ButterKnife.bind(this, view);
    setupView(list);
    listView.addHeaderView(view);
}
 
Example 19
Project: GitHub   File: BaseFragment.java   View Source Code Vote up 4 votes
protected void setDummyDataWithHeader(ListView listView, View headerView) {
    listView.addHeaderView(headerView);
    setDummyData(listView);
}
 
Example 20
Project: CSipSimple   File: AccountsEditListFragment.java   View Source Code Vote up 4 votes
@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.
        curCheckPosition = 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 AccountsEditListAdapter(getActivity(), null);
        mAdapter.setOnCheckedRowListener(this);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);
        
        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);
    }
}