Java Code Examples for android.widget.ExpandableListView#setAdapter()

The following examples show how to use android.widget.ExpandableListView#setAdapter() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainExpListActivity.java    From ListView-Swipe-to-Delete with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_explist);

	list = (ExpandableListView) findViewById(android.R.id.list);
	
	listHandler = new ItemExpListHandler(list);
	
	ArrayList<MenuItemDesc> menuItems = fillMenu();
	
	listAdapter = new ItemExpListAdapter(R.layout.item, menuItems, listHandler);
	fillAdapter();
	list.setAdapter(listAdapter);

	listManager = new ItemExpListManager(this, listHandler, true);
}
 
Example 2
Source File: GenericChannelsFragment.java    From buddycloud-android with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	View view = inflater.inflate(R.layout.channel_list, container, false);
	
	OnChildClickListener channelItemListener = new OnChildClickListener() {
		@Override
		public boolean onChildClick(ExpandableListView parent, View v,
				int groupPosition, int childPosition, long id) {
			JSONObject channelItem = (JSONObject) adapter.getChild(groupPosition, childPosition);
			channelSelected(channelItem);
			return true;
		}
	};
	
	ExpandableListView channelsView = (ExpandableListView) view.findViewById(R.id.channelListView);
	channelsView.setEmptyView(view.findViewById(R.id.channelListProgress));
	channelsView.setAdapter(adapter);
	channelsView.setOnChildClickListener(channelItemListener);
	
	PauseOnScrollListener listener = new PauseOnScrollListener(ImageLoader.getInstance(), true, true);
	channelsView.setOnScrollListener(listener);
	expandAll(view);
	
	return view;
}
 
Example 3
Source File: elvDemo2_Fragment.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo2_fragment, container, false);
	
    // get the listview
       expListView = (ExpandableListView) myView.findViewById(R.id.lvExp2);
       prepareListData();
       
       listAdapter =  new SimpleExpandableListAdapter(
                       myContext,						    //context
                       listDataGroup,                  // group list in the form:  List<? extends Map<String, ?>>
                       R.layout.evl2_group_row,        // Group item layout XML.
                       new String[] { "Group Item" },  // the key of group item.   String[] groupFrom, 
                       new int[] { R.id.row_name },    // ID of each group item.-Data under the key goes into this TextView.  int[] groupTo
                       listDataChild,              // childData describes second-level entries. in the form List<? extends List<? extends Map<String, ?>>>
                       R.layout.evl2_child_row,             // Layout for sub-level entries(second level).
                       new String[] {"Sub Item A", "Sub Item B"},      // Keys in childData maps to display.
                       new int[] { R.id.grp_childA, R.id.grp_childB}     // Data under the keys above go into these TextViews.
                   );
      expListView.setAdapter( listAdapter );       // setting the adapter in the list.
    
       return myView;
}
 
Example 4
Source File: elvDemo2_Fragment.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo2_fragment, container, false);
	
    // get the listview
       expListView = (ExpandableListView) myView.findViewById(R.id.lvExp2);
       prepareListData();
       
       listAdapter =  new SimpleExpandableListAdapter(
                       myContext,						    //context
                       listDataGroup,                  // group list in the form:  List<? extends Map<String, ?>>
                       R.layout.evl2_group_row,        // Group item layout XML.
                       new String[] { "Group Item" },  // the key of group item.   String[] groupFrom, 
                       new int[] { R.id.row_name },    // ID of each group item.-Data under the key goes into this TextView.  int[] groupTo
                       listDataChild,              // childData describes second-level entries. in the form List<? extends List<? extends Map<String, ?>>>
                       R.layout.evl2_child_row,             // Layout for sub-level entries(second level).
                       new String[] {"Sub Item A", "Sub Item B"},      // Keys in childData maps to display.
                       new int[] { R.id.grp_childA, R.id.grp_childB}     // Data under the keys above go into these TextViews.
                   );
      expListView.setAdapter( listAdapter );       // setting the adapter in the list.
    
       return myView;
}
 
Example 5
Source File: HelpActivity.java    From privacy-friendly-qr-scanner with GNU General Public License v3.0 6 votes vote down vote up
@SuppressLint("RestrictedApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);
    getSupportActionBar().setDefaultDisplayHomeAsUpEnabled(true);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);

}
 
Example 6
Source File: elvDemo1_Fragment.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo1_fragment, container, false);


	// get the listview
	expListView = (ExpandableListView) myView.findViewById(R.id.lvExp);

	// preparing list data
	prepareListData();

	listAdapter = new ExpandableListAdapter(myContext, listDataHeader, listDataChild);

	// setting list adapter
	expListView.setAdapter(listAdapter);
	
	return myView;
}
 
Example 7
Source File: HelpActivity.java    From privacy-friendly-weather with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_help);
    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
Example 8
Source File: OPDSActivity.java    From document-viewer with GNU General Public License v3.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @see org.emdev.ui.AbstractActionActivity#onCreateImpl(android.os.Bundle)
 */
@Override
protected void onCreateImpl(final Bundle savedInstanceState) {

    setContentView(R.layout.opds);
    setActionForView(R.id.opdsaddfeed);

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    
    final OPDSActivityController c = getController();

    list = (ExpandableListView) findViewById(R.id.opdslist);
    list.setGroupIndicator(null);
    list.setChildIndicator(null);
    list.setOnGroupClickListener(c);
    list.setOnChildClickListener(c);
    list.setAdapter(c.adapter);

    this.registerForContextMenu(list);
}
 
Example 9
Source File: RecentTabsPage.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 10
Source File: ResultsActivity.java    From arcgis-runtime-samples-android with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstance) {
  super.onCreate(savedInstance);
  setContentView(R.layout.results_expandable_list);

  // get intent from main activity
  Intent intent = getIntent();
  // get the HashMap created in MainActivity
  HashMap<String,ArrayList<String>> child = (HashMap<String,ArrayList<String>>) intent.getSerializableExtra("HashMap");
  ArrayList<String> header = new ArrayList<>();
  header.add("Point");
  header.add("Polyline");
  header.add("Polygon");

  // create an expandable list view and an adapter to display in new activity.
  ExpandableListView expandableListView = findViewById(R.id.expandableList);
  ExpandableListAdapter expandableListAdapter = new ExpandableListAdapter(this,header,child);
  expandableListView.setAdapter(expandableListAdapter);
}
 
Example 11
Source File: HelpActivity.java    From privacy-friendly-passwordgenerator with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    ExpandableListAdapter expandableListAdapter;
    HelpDataDump helpDataDump = new HelpDataDump(this);

    ExpandableListView generalExpandableListView = (ExpandableListView) findViewById(R.id.generalExpandableListView);

    LinkedHashMap<String, List<String>> expandableListDetail = helpDataDump.getDataGeneral();
    List<String> expandableListTitleGeneral = new ArrayList<String>(expandableListDetail.keySet());
    expandableListAdapter = new ExpandableListAdapter(this, expandableListTitleGeneral, expandableListDetail);
    generalExpandableListView.setAdapter(expandableListAdapter);

    overridePendingTransition(0, 0);
}
 
Example 12
Source File: RecentTabsPage.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(Activity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = buildAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    onUpdated();
}
 
Example 13
Source File: elvDemo1_Fragment.java    From ui with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
		Bundle savedInstanceState) {
	// Inflate the layout for this fragment
	View myView = inflater.inflate(R.layout.elvdemo1_fragment, container, false);


	// get the listview
	expListView = (ExpandableListView) myView.findViewById(R.id.lvExp);

	// preparing list data
	prepareListData();

	listAdapter = new ExpandableListAdapter(myContext, listDataHeader, listDataChild);

	// setting list adapter
	expListView.setAdapter(listAdapter);
	
	return myView;
}
 
Example 14
Source File: InfoActivity.java    From Bluefruit_LE_Connect_Android with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_info);

    mBleManager = BleManager.getInstance(this);

    // Init variables
    restoreRetainedDataFragment();

    // UI
    mWaitView = findViewById(R.id.waitView);

    mInfoListView = (ExpandableListView) findViewById(R.id.infoListView);
    mInfoListAdapter = new ExpandableListAdapter(this, mServicesList, mCharacteristicsMap, mDescriptorsMap, mValuesMap);
    mInfoListView.setAdapter(mInfoListAdapter);

    BluetoothDevice device = mBleManager.getConnectedDevice();
    if (device != null) {
        TextView nameTextView = (TextView) findViewById(R.id.nameTextView);
        boolean isNameDefined = device.getName() != null;
        nameTextView.setText(device.getName());
        nameTextView.setVisibility(isNameDefined ? View.VISIBLE : View.GONE);

        TextView addressTextView = (TextView) findViewById(R.id.addressTextView);
        final String address = String.format("%s: %s", getString(R.string.scan_device_address), device.getAddress());
        addressTextView.setText(address);

        onServicesDiscovered();
    } else {
        finish();       // Device disconnected for unknown reason
    }
}
 
Example 15
Source File: RecentTabsPage.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor returns an instance of RecentTabsPage.
 *
 * @param activity The activity this view belongs to.
 * @param recentTabsManager The RecentTabsManager which provides the model data.
 */
public RecentTabsPage(ChromeActivity activity, RecentTabsManager recentTabsManager) {
    mActivity = activity;
    mRecentTabsManager = recentTabsManager;

    mTitle = activity.getResources().getString(R.string.recent_tabs);
    mThemeColor = ApiCompatibilityUtils.getColor(
            activity.getResources(), R.color.default_primary_color);
    mRecentTabsManager.setUpdatedCallback(this);
    LayoutInflater inflater = LayoutInflater.from(activity);
    mView = (ViewGroup) inflater.inflate(R.layout.recent_tabs_page, null);
    mListView = (ExpandableListView) mView.findViewById(R.id.odp_listview);
    mAdapter = new RecentTabsRowAdapter(activity, recentTabsManager);
    mListView.setAdapter(mAdapter);
    mListView.setOnChildClickListener(this);
    mListView.setGroupIndicator(null);
    mListView.setOnGroupCollapseListener(this);
    mListView.setOnGroupExpandListener(this);
    mListView.setOnCreateContextMenuListener(this);

    mView.addOnAttachStateChangeListener(this);
    ApplicationStatus.registerStateListenerForActivity(this, activity);
    // {@link #mInForeground} will be updated once the view is attached to the window.

    if (activity.getBottomSheet() != null) {
        View recentTabsRoot = mView.findViewById(R.id.recent_tabs_root);
        ApiCompatibilityUtils.setPaddingRelative(recentTabsRoot,
                ApiCompatibilityUtils.getPaddingStart(recentTabsRoot), 0,
                ApiCompatibilityUtils.getPaddingEnd(recentTabsRoot),
                activity.getResources().getDimensionPixelSize(
                        R.dimen.bottom_control_container_height));
    }

    onUpdated();
}
 
Example 16
Source File: DetailFragment.java    From Android-Applications-Info with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    mLayoutInflater = inflater;

    ExpandableListView listView = new ExpandableListView(getActivity());
    listView.setGroupIndicator(null);

    if (mPackageInfo == null) {
        Toast.makeText(getActivity(), R.string.app_not_installed, Toast.LENGTH_LONG).show();
    } else {
        listView.setAdapter(new Adapter());
    }

    return listView;
}
 
Example 17
Source File: LauncherActivity.java    From android-apps with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.activity_launcher);
	
	promoExpandableListView = (ExpandableListView) findViewById(R.id.expandPromoList);
	prepareItemListData();
	
	try{
		promoMaterialsListAdapter = new PromoMaterialsListAdapter(this , headerDataList, childDataList);
		promoExpandableListView.setAdapter(promoMaterialsListAdapter);
	} catch(Exception e){}
}
 
Example 18
Source File: HelpActivity.java    From privacy-friendly-food-tracker with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_help);

    LinkedHashMap<String, List<String>> expandableListDetail = buildData();

    ExpandableListView generalExpandableListView = findViewById(R.id.generalExpandableListView);
    generalExpandableListView.setAdapter(new HelpExpandableListAdapter(this, new ArrayList<>(expandableListDetail.keySet()), expandableListDetail));

    overridePendingTransition(0, 0);
}
 
Example 19
Source File: MainFragment.java    From Inspeckage with Apache License 2.0 4 votes vote down vote up
private void loadListView(View view) {
    List<String> mListDataHeader = new ArrayList<String>();
    mListDataHeader.add(context.getString(R.string.fragment_config_choose));

    HashMap<String, List<ExpandableListItem>> mListDataChild = new HashMap<String, List<ExpandableListItem>>();

    ArrayList<ExpandableListItem> mApps = getInstalledApps();
    Collections.sort(mApps, new Comparator<ExpandableListItem>() {

        public int compare(ExpandableListItem o1, ExpandableListItem o2) {
            return o1.getAppName().compareTo(o2.getAppName());
        }
    });

    ExpandableListView appList = (ExpandableListView) view.findViewById(R.id.appsListView);


    mListDataChild.put(mListDataHeader.get(0), mApps);
    appList.setAdapter(new ExpandableListAdapter(getActivity(), mListDataHeader, mListDataChild));

}
 
Example 20
Source File: DeploymentDetailsActivity.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_deployment_details);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar supportActionBar = getSupportActionBar();
    if (supportActionBar != null) {
        supportActionBar.setDisplayHomeAsUpEnabled(true);
    }

    if(android.os.Build.VERSION.SDK_INT >= 21) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.osm_light_green));
    }

    Intent intent = getIntent();
    int position = intent.getIntExtra("POSITION", 0);
    deployment = Deployments.singleton().get(position);
    deployment.setDownloaderListener(this);

    String title = deployment.title();
    TextView nameTextView = (TextView)findViewById(R.id.nameTextView);
    nameTextView.setText(title);

    JSONObject manifest = deployment.json().optJSONObject("manifest");
    if (manifest != null) {
        String description = manifest.optString("description");
        TextView descriptionTextView = (TextView)findViewById(R.id.descriptionTextView);
        descriptionTextView.setText(description);
    }

    progressTextView = (TextView)findViewById(R.id.progressTextView);
    progressBar = (ProgressBar)findViewById(R.id.progressBar);
    progressBar.setMax((int)deployment.totalSize());

    /**
     * SETUP FOR EXPANDABLE LIST VIEW FOR MBTILES AND OSM FILES
     */
    ExpandableListView expandableListView = (ExpandableListView) findViewById(R.id.expandableListView);
    FileExpandableListAdapter fileExpandableListAdapter = new FileExpandableListAdapter(this, deployment);
    expandableListView.setAdapter(fileExpandableListAdapter);

    /**
     * FAB to initiate downloads.
     */
    fab = (FloatingActionButton)findViewById(R.id.fab);
    fab.setOnClickListener(this);

    checkoutFab = (FloatingActionButton)findViewById(R.id.fab_checkout_deployment);

    setFreshUIState();
}