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

The following are Jave code examples for showing how to use addFooterView() 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: 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 2
Project: OSchina_resources_android   File: BaseListFragment.java   View Source Code Vote up 6 votes
@Override
protected void initWidget(View root) {
    super.initWidget(root);
    mListView = (ListView) root.findViewById(R.id.listView);
    mRefreshLayout = (SuperRefreshLayout) root.findViewById(R.id.superRefreshLayout);
    mRefreshLayout.setColorSchemeResources(
            R.color.swiperefresh_color1, R.color.swiperefresh_color2,
            R.color.swiperefresh_color3, R.color.swiperefresh_color4);
    mErrorLayout = (EmptyLayout) root.findViewById(R.id.error_layout);
    mRefreshLayout.setSuperRefreshLayoutListener(this);
    mFooterView = LayoutInflater.from(getContext()).inflate(R.layout.layout_list_view_footer, null);
    mFooterText = (TextView) mFooterView.findViewById(R.id.tv_footer);
    mFooterProgressBar = (ProgressBar) mFooterView.findViewById(R.id.pb_footer);
    mListView.setOnItemClickListener(this);

    mErrorLayout.setOnLayoutClickListener(this);
    if (isNeedFooter())
        mListView.addFooterView(mFooterView);
}
 
Example 3
Project: Raffler-Android   File: AlertView.java   View Source Code Vote up 5 votes
protected void initListView(){
    Context context = contextWeak.get();
    if(context == null) return;

    ListView alertButtonListView = (ListView) contentContainer.findViewById(R.id.alertButtonListView);

    if(cancel != null && style == Style.Alert){
        View itemView = LayoutInflater.from(context).inflate(R.layout.item_actionsheetbutton, null);
        TextView tvAlert = (TextView) itemView.findViewById(R.id.tvAlert);
        tvAlert.setText(cancel);
        tvAlert.setClickable(true);
        tvAlert.setTypeface(Typeface.DEFAULT_BOLD);
        tvAlert.setTextColor(context.getResources().getColor(R.color.textColor_alert_button_cancel));
        tvAlert.setBackgroundResource(R.drawable.bg_alertbutton_bottom);
        tvAlert.setOnClickListener(new OnTextClickListener(CANCELPOSITION));
        alertButtonListView.addFooterView(itemView);
    }
    AlertViewAdapter adapter = new AlertViewAdapter(mDatas,mDestructive);
    alertButtonListView.setAdapter(adapter);
    alertButtonListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            if(onItemClickListener != null)onItemClickListener.onItemClick(AlertView.this,position);
            dismiss();
        }
    });
}
 
Example 4
Project: goRefresh   File: LoadMoreHelper.java   View Source Code Vote up 5 votes
public void addListViewFooterView(ListView listView, int flag) {
    if (mFooterView != null && mFooterStatus != flag) {
        return;
    }
    removeFooterView(listView);
    if (flag == LOADING) {
        mFooterView = mFooter.getLoadingView();
    } else if (flag == FINISH) {
        mFooterView = mFooter.getFinishView();
    } else if (flag == ERROR) {
        mFooterView = mFooter.getFailureView();
    }
    listView.addFooterView(mFooterView);
}
 
Example 5
Project: weather-mvp   File: MarkedCountyActivity.java   View Source Code Vote up 5 votes
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_marked_county);
    listView = (ListView) findViewById(R.id.marked_county_list);
    foot_view = LayoutInflater.from(this).inflate(R.layout.foot_view, null);
    addCounty = (Button) foot_view.findViewById(R.id.add_marked_county);

    mAdapter = new CountyListAdapter(this, R.layout.item_marked_county, mCountyList);
    listView.addFooterView(foot_view);
    listView.setAdapter(mAdapter);
    listView.setOnItemClickListener(this);
    addCounty.setOnClickListener(this);
    showMarkedCounty();
}
 
Example 6
Project: NeiHanDuanZiTV   File: AlertView.java   View Source Code Vote up 5 votes
protected void initListView(){
    Context context = contextWeak.get();
    if(context == null) return;

    ListView alertButtonListView = (ListView) contentContainer.findViewById(R.id.alertButtonListView);
    //把cancel作为footerView
    if(cancel != null && style == Style.Alert){
        View itemView = LayoutInflater.from(context).inflate(R.layout.item_alertbutton, null);
        TextView tvAlert = (TextView) itemView.findViewById(R.id.tvAlert);
        tvAlert.setText(cancel);
        tvAlert.setClickable(true);
        tvAlert.setTypeface(Typeface.DEFAULT_BOLD);
        tvAlert.setTextColor(context.getResources().getColor(R.color.textColor_alert_button_cancel));
        tvAlert.setBackgroundResource(R.drawable.bg_alertbutton_bottom);
        tvAlert.setOnClickListener(new OnTextClickListener(CANCELPOSITION));
        alertButtonListView.addFooterView(itemView);
    }
    AlertViewAdapter adapter = new AlertViewAdapter(mDatas,mDestructive);
    alertButtonListView.setAdapter(adapter);
    alertButtonListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
            if(onItemClickListener != null)onItemClickListener.onItemClick(AlertView.this,position);
            dismiss();
        }
    });
}
 
Example 7
Project: TaipeiTechRefined   File: ActivityFragment.java   View Source Code Vote up 5 votes
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    fragmentView = inflater.inflate(R.layout.fragment_activity, container,
            false);
    swipeLayout = (SwipeRefreshLayout) fragmentView
            .findViewById(R.id.swipe_container);
    swipeLayout.setColorSchemeResources(R.color.yellow, R.color.orange,
            R.color.red, R.color.purple, R.color.blue, R.color.green);
    swipeLayout.setOnRefreshListener(this);
    listView = (ListView) fragmentView.findViewById(R.id.activity_listview);
    View header = inflater.inflate(R.layout.activity_divider, listView,
            false);
    listView.addHeaderView(header);
    View footer = inflater.inflate(R.layout.activity_divider, listView,
            false);
    listView.addFooterView(footer);
    View start_button = fragmentView.findViewById(R.id.start_button);
    start_button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            updateActivity();
        }
    });
    return fragmentView;
}
 
Example 8
Project: R-a-dio-Amazing-Android-App   File: ActivityMain.java   View Source Code Vote up 4 votes
public void setSongList(String json) throws JSONException{
    View requestView = viewPager.findViewById(R.id.requests_page);
    TextView searchMsg = (TextView) requestView.findViewById(R.id.searchMsg);
    ListView songListView = (ListView) requestView.findViewById(R.id.songListView);
    Integer curPage, lastPage;

    try {
        JSONObject searchObject = new JSONObject(json);
        JSONArray songs = new JSONArray(searchObject.getString("data"));
        ArrayList<Song> songList = new ArrayList<>();
        curPage = searchObject.getInt("current_page");
        lastPage = searchObject.getInt("last_page");

        for (int i = 0; i < songs.length(); i++){
            JSONObject songObject = songs.getJSONObject(i);

            if(songObject != null){
                String artist = songObject.getString("artist");
                String title = songObject.getString("title");
                Integer songID = songObject.getInt("id");
                boolean requestable = songObject.getBoolean("requestable");
                Song song = new Song(artist, title, songID, requestable);

                songList.add(song);
            }
        }

        if(songs.length() == 0) {
            searchMsg.setVisibility(View.VISIBLE);
            searchMsg.setText("No songs found for query.");
        } else {
            searchMsg.setVisibility(View.INVISIBLE);
        }

        if(searchFooter == null || songListView.getFooterViewsCount() == 0) {
            createSearchFooter(curPage, lastPage);
            songListView.addFooterView(searchFooter);
        }
        else {
            createSearchFooter(curPage, lastPage);
        }
        SongAdapter sAdapt = new SongAdapter(this, R.layout.request_cell, songList);
        songListView.setAdapter(sAdapt);
    }
    catch(JSONException ex){
        searchMsg.setVisibility(View.VISIBLE);
        searchMsg.setText("An error occurred while retrieving songs. Please try again.");
    }
}
 
Example 9
Project: ListPageDemo   File: LoadMoreActivity.java   View Source Code Vote up 4 votes
private void showData(List<Student> data) {

        if (mAdapter == null) {

            mListView = (ListView) findViewById(R.id.mListView);

            mFooterView = LayoutInflater.from(this).inflate(R.layout.footer_item,null);
            mFooterView.setVisibility(View.GONE);

            mListView.addFooterView(mFooterView);

            mAdapter = new ListViewAdapter(this, data);

            mListView.setAdapter(mAdapter);

        } else {

            mData = data;

            mAdapter.notifyDataSetChanged();

        }

    }