Example usage for android.widget ListView ListView

List of usage examples for android.widget ListView ListView

Introduction

In this page you can find the example usage for android.widget ListView ListView.

Prototype

public ListView(Context context, AttributeSet attrs, int defStyleAttr) 

Source Link

Usage

From source file:com.wit.and.dialog.ListDialog.java

/**
 * <p>//from w  ww  . j ava  2 s.  c  o m
 * Invoked to create dialog list view.
 * </p>
 * <p>
 * Here is the best place to provide custom list view.
 * </p>
 *
 * @param inflater           Layout inflater.
 * @param container          Layout created in the {@link #onCreateBodyView(android.view.LayoutInflater, android.view.ViewGroup, android.os.Bundle)}
 * @param savedInstanceState Saved dialog state.
 * @return Created dialog list view.
 */
protected ListView onCreateListView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ListView listView;

    final ListOptions options = getOptions();
    if (options.getListViewRes() != DEFAULT_RES) {
        // Inflate custom list view.
        listView = (ListView) inflater.inflate(options.getListViewRes(), null, false);
    } else {
        // Create default list view.
        listView = new ListView(inflater.getContext(), null, android.R.attr.listViewStyle);
        listView.setId(R.id.And_Dialog_ListView);
        RelativeLayout.LayoutParams listViewParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        listViewParams.addRule(RelativeLayout.CENTER_IN_PARENT);
        listView.setLayoutParams(listViewParams);
    }
    return listView;
}