android.widget.ExpandableListView.OnChildClickListener#android.widget.ExpandableListAdapter源码实例Demo

下面列出了android.widget.ExpandableListView.OnChildClickListener#android.widget.ExpandableListAdapter 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Social   文件: ListViewUtil.java
/**
     * 可扩展listview展开时调用
     *
     * @param listView
     * @param groupPosition
     */
    public static void setExpandedListViewHeightBasedOnChildren(
            ExpandableListView listView, int groupPosition) {
        ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
        if (listAdapter == null) {
            return;
        }
        View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
                listView);
        listItem.measure(0, 0);
        int appendHeight = 0;
        for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
            appendHeight += listItem.getMeasuredHeight();
        }
        ViewGroup.LayoutParams params = listView.getLayoutParams();
//        Log.d(TAG, "Expand params.height" + params.height);
        params.height += appendHeight;
        listView.setLayoutParams(params);
    }
 
源代码2 项目: Social   文件: ListViewUtil.java
/**
 * 可扩展listview收起时调用
 *
 * @param listView
 * @param groupPosition
 */
public static void setCollapseListViewHeightBasedOnChildren(
        ExpandableListView listView, int groupPosition) {
    ExpandableListAdapter listAdapter = listView.getExpandableListAdapter();
    if (listAdapter == null) {
        return;
    }
    View listItem = listAdapter.getChildView(groupPosition, 0, true, null,
            listView);
    listItem.measure(0, 0);
    int appendHeight = 0;
    for (int i = 0; i < listAdapter.getChildrenCount(groupPosition); i++) {
        appendHeight += listItem.getMeasuredHeight();
    }
    /*Log.d(TAG,
            "Collapse childCount="
                    + listAdapter.getChildrenCount(groupPosition));*/
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height -= appendHeight;
    listView.setLayoutParams(params);
}
 
源代码3 项目: FireFiles   文件: RootsFragment.java
private ArrayList<Long> getExpandedIds() {
    ExpandableListView list = mList;
    ExpandableListAdapter adapter = mAdapter;
    if (adapter != null) {
        int length = adapter.getGroupCount();
        ArrayList<Long> expandedIds = new ArrayList<Long>();
        for(int i=0; i < length; i++) {
            if(list.isGroupExpanded(i)) {
                expandedIds.add(adapter.getGroupId(i));
            }
        }
        return expandedIds;
    } else {
        return null;
    }
}
 
源代码4 项目: FireFiles   文件: RootsFragment.java
private ArrayList<Long> getExpandedIds() {
    ExpandableListView list = mList;
    ExpandableListAdapter adapter = mAdapter;
    if (adapter != null) {
        int length = adapter.getGroupCount();
        ArrayList<Long> expandedIds = new ArrayList<Long>();
        for(int i=0; i < length; i++) {
            if(list.isGroupExpanded(i)) {
                expandedIds.add(adapter.getGroupId(i));
            }
        }
        return expandedIds;
    } else {
        return null;
    }
}
 
源代码5 项目: FireFiles   文件: RootsFragment.java
private ArrayList<Long> getExpandedIds() {
    ExpandableListView list = mList;
    ExpandableListAdapter adapter = mAdapter;
    if (adapter != null) {
        int length = adapter.getGroupCount();
        ArrayList<Long> expandedIds = new ArrayList<Long>();
        for(int i=0; i < length; i++) {
            if(list.isGroupExpanded(i)) {
                expandedIds.add(adapter.getGroupId(i));
            }
        }
        return expandedIds;
    } else {
        return null;
    }
}
 
@Override protected void onCreate(@Nullable Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.results_expandablelistview);

  Gson gson = new Gson();

  LinkedHashMap<String, List<String>> groupedStatistics = gson
      .fromJson(results, new ResultsActivity.LinkedHashMapTypeToken().getType());

  // create expandable list view
  ExpandableListView expandableListView = findViewById(R.id.expandableListView);
  ExpandableListAdapter expandableListAdapter = new ExpandableListViewAdapter(this, groupedStatistics);
  expandableListView.setAdapter(expandableListAdapter);
  // expand the first group by default
  expandableListView.expandGroup(0);
}
 
源代码7 项目: opentasks   文件: RetainExpandableListView.java
public void expandGroups(long[] groupsToExpand)
{
    // this.expandedIds = expandedIds;
    if (groupsToExpand != null && groupsToExpand.length > 0)
    {
        ExpandableListAdapter adapter = getExpandableListAdapter();
        if (adapter != null)
        {
            for (int i = 0; i < adapter.getGroupCount(); i++)
            {
                long id = adapter.getGroupId(i);
                if (inArray(groupsToExpand, id))
                {
                    expandGroup(i);
                }
            }
        }
    }
}
 
源代码8 项目: opentasks   文件: TaskListFragment.java
private void selectChildView(ExpandableListView expandLV, int groupPosition, int childPosition, boolean force)
{
    if (groupPosition < mAdapter.getGroupCount() && childPosition < mAdapter.getChildrenCount(groupPosition))
    {
        // a task instance element has been clicked, get it's instance id and notify the activity
        ExpandableListAdapter listAdapter = expandLV.getExpandableListAdapter();
        Cursor cursor = (Cursor) listAdapter.getChild(groupPosition, childPosition);

        if (cursor == null)
        {
            return;
        }

        Uri taskUri = ContentUris.withAppendedId(Instances.getContentUri(mAuthority), (long) TaskFieldAdapters.TASK_ID.get(cursor));
        Color taskListColor = new ValueColor(TaskFieldAdapters.LIST_COLOR.get(cursor));
        mCallbacks.onItemSelected(taskUri, taskListColor, force, mInstancePosition);
    }
}
 
/**
 * Provide the adapter for the expandable list.
 */
public void setListAdapter(ExpandableListAdapter adapter) {
    synchronized (this) {
        ensureList();
        mAdapter = adapter;
        mList.setAdapter(adapter);
    }
}
 
源代码10 项目: AndroidQuick   文件: AnimatedExpandableListView.java
/**
 * @see ExpandableListView#setAdapter(ExpandableListAdapter)
 */
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);

    // Make sure that the adapter extends AnimatedExpandableListAdapter
    if(adapter instanceof AnimatedExpandableListAdapter) {
        this.adapter = (AnimatedExpandableListAdapter) adapter;
        this.adapter.setParent(this);
    } else {
        throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter");
    }
}
 
源代码11 项目: FireFiles   文件: RootsFragment.java
private void restoreExpandedState(ArrayList<Long> expandedIds) {
    this.expandedIds = expandedIds;
    if (expandedIds != null) {
        ExpandableListView list = mList;
        ExpandableListAdapter adapter = mAdapter;
        if (adapter != null) {
            for (int i=0; i<adapter.getGroupCount(); i++) {
                long id = adapter.getGroupId(i);
                if (expandedIds.contains(id)) list.expandGroup(i);
            }
        }
    }
}
 
源代码12 项目: FireFiles   文件: RootsFragment.java
private void restoreExpandedState(ArrayList<Long> expandedIds) {
    this.expandedIds = expandedIds;
    if (expandedIds != null) {
        ExpandableListView list = mList;
        ExpandableListAdapter adapter = mAdapter;
        if (adapter != null) {
            for (int i=0; i<adapter.getGroupCount(); i++) {
                long id = adapter.getGroupId(i);
                if (expandedIds.contains(id)) list.expandGroup(i);
            }
        }
    }
}
 
源代码13 项目: FireFiles   文件: RootsFragment.java
private void restoreExpandedState(ArrayList<Long> expandedIds) {
    this.expandedIds = expandedIds;
    if (expandedIds != null) {
        ExpandableListView list = mList;
        ExpandableListAdapter adapter = mAdapter;
        if (adapter != null) {
            for (int i=0; i<adapter.getGroupCount(); i++) {
                long id = adapter.getGroupId(i);
                if (expandedIds.contains(id)) list.expandGroup(i);
            }
        }
    }
}
 
/**
 * @see ExpandableListView#setAdapter(ExpandableListAdapter)
 */
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);

    // Make sure that the adapter extends AnimatedExpandableListAdapter
    if (adapter instanceof AnimatedExpandableListAdapter) {
        this.adapter = (AnimatedExpandableListAdapter) adapter;
        this.adapter.setParent(this);
    } else {
        throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter");
    }
}
 
/**
 * Provide the adapter for the expandable list.
 */
public void setListAdapter(final ExpandableListAdapter adapter) {
	synchronized (this) {
		ensureList();
		this.adapter = adapter;
		list.setAdapter(adapter);
	}
}
 
源代码16 项目: qiniu-lab-android   文件: QiniuLabMainActivity.java
private void inflateExpandableListView() {
    this.exampleGroupTitleList.add(this
            .getString(R.string.qiniu_quick_start));
    this.exampleGroupTitleList.add(this
            .getString(R.string.qiniu_simple_upload));
    this.exampleGroupTitleList.add(this
            .getString(R.string.qiniu_advanced_upload));
    this.exampleGroupTitleList.add(this
            .getString(R.string.qiniu_audio_video_play));
    this.exampleGroupTitleList.add(this
            .getString(R.string.qiniu_image_view));
    this.exampleGroupTitleList.add(this
            .getString(R.string.qiniu_system_capture));

    this.exampleItemTitleList.add(Arrays.asList(this.getResources()
            .getStringArray(R.array.qiniu_quick_start_demo)));
    this.exampleItemTitleList.add(Arrays.asList(this.getResources()
            .getStringArray(R.array.qiniu_simple_upload_values)));
    this.exampleItemTitleList.add(Arrays.asList(this.getResources()
            .getStringArray(R.array.qiniu_advanced_upload_values)));
    this.exampleItemTitleList.add(Arrays.asList(this.getResources()
            .getStringArray(R.array.qiniu_video_play)));
    this.exampleItemTitleList.add(Arrays.asList(this.getResources()
            .getStringArray(R.array.qiniu_image_view)));
    this.exampleItemTitleList.add(Arrays.asList(this.getResources()
            .getStringArray(R.array.qiniu_system_capture)));
    ExpandableListAdapter exampleListViewAdapter = new ExampleExpandableListAdapter(
            this, this.exampleGroupTitleList, this.exampleItemTitleList);
    this.exampleListView.setAdapter(exampleListViewAdapter);
    OnExampleItemClickListener onExampleItemClickListener = new OnExampleItemClickListener(
            this);
    this.exampleListView
            .setOnChildClickListener(onExampleItemClickListener);
}
 
源代码17 项目: TreeView   文件: TreeView.java
@Override
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);

    if(adapter instanceof ITreeViewHeaderUpdater) {
        mUpdater = (ITreeViewHeaderUpdater) adapter;
    } else {
        throw new IllegalArgumentException("The adapter must instanceof ITreeViewHeaderUpdater.");
    }
}
 
/**
 * @see ExpandableListView#setAdapter(ExpandableListAdapter)
 */
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);

    // Make sure that the adapter extends AnimatedExpandableListAdapter
    if(adapter instanceof AnimatedExpandableListAdapter) {
        this.adapter = (AnimatedExpandableListAdapter) adapter;
        this.adapter.setParent(this);
    } else {
        throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter");
    }
}
 
源代码19 项目: QuickLyric   文件: AnimatedExpandableListView.java
/**
 * @see ExpandableListView#setAdapter(ExpandableListAdapter)
 */
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);

    // Make sure that the adapter extends AnimatedExpandableListAdapter
    if (adapter instanceof AnimatedExpandableListAdapter) {
        this.adapter = (AnimatedExpandableListAdapter) adapter;
        this.adapter.setParent(this);
    } else {
        throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter");
    }
}
 
@Override
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);

    if (adapter instanceof AnimatedExpandableListAdapter) {
        this.adapter = (AnimatedExpandableListAdapter) adapter;
    } else {
        throw new ClassCastException(adapter.toString() + " must implement AnimatedExpandableListAdapter");
    }
}
 
@Override
public void setAdapter(ExpandableListAdapter adapter) {
	if(!(adapter instanceof WrapperExpandableListAdapter)) {
		throw new IllegalArgumentException("The adapter must be an instance of WrapperExpandableListAdapter");
	}
	setAdapter((WrapperExpandableListAdapter) adapter);
}
 
源代码22 项目: dynamiclistview   文件: DynamicSectionListView.java
@Override
public void setAdapter(ExpandableListAdapter adapter) {

    if (!(adapter instanceof BaseSectionAdapter)) {
        System.err.print("SectionListView need BaseSectionAdapter");
        return;
    }
    super.setAdapter(adapter);
    mAdapter = (BaseSectionAdapter) adapter;

    if (mAlwaysExpanded) {
        openGroup();
        fixOpenedGroup();
    }
}
 
源代码23 项目: opentasks   文件: RetainExpandableListView.java
public long[] getExpandedGroups()
{
    ExpandableListAdapter adapter = this.getExpandableListAdapter();
    int count = adapter.getGroupCount();
    ArrayList<Long> expandedIds = new ArrayList<Long>();
    for (int i = 0; i < count; i++)
    {
        if (this.isGroupExpanded(i))
        {
            expandedIds.add(adapter.getGroupId(i));
        }
    }
    return toLongArray(expandedIds);
}
 
源代码24 项目: assertj-android   文件: ExpandableListViewAssert.java
public ExpandableListViewAssert hasExpandableListAdapter(ExpandableListAdapter adapter) {
  isNotNull();
  ExpandableListAdapter actualAdapter = actual.getExpandableListAdapter();
  assertThat(actualAdapter) //
      .overridingErrorMessage("Expected expandable list adapter <%s> but was <%s>.", adapter,
          actualAdapter) //
      .isSameAs(adapter);
  return this;
}
 
源代码25 项目: dbclf   文件: SimpleListActivity.java
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_list);

    final String lang = Locale.getDefault().getLanguage();
    if (translations.contains(lang)) {
        wikiLangSubDomain = lang + ".";
    }

    recogs = getIntent().getStringArrayListExtra("recogs");

    expListView = findViewById(R.id.lvExp);

    prepareListData();

    final ExpandableListAdapter listAdapter = new ListAdapter(this, listDataHeader, listDataChild);

    expListView.setOnChildClickListener((parent, v, groupPosition, childPosition, id) -> {
        final String title = listDataHeader.get(groupPosition);
        final String searchText = title.replace(" ", "+");

        final DialogInterface.OnClickListener dialogClickListener = (dialog, which) -> {
            switch (which) {
                case DialogInterface.BUTTON_POSITIVE:
                    final String url = String.format("https://%swikipedia.org/w/index.php?search=%s&title=Special:Search", wikiLangSubDomain, searchText);

                    final Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    startActivity(i);
                    break;

                case DialogInterface.BUTTON_NEGATIVE:
                    break;
            }
        };

        (new AlertDialog.Builder(this))
                .setMessage(R.string.searchFor).setTitle(title)
                .setNegativeButton(R.string.no, dialogClickListener)
                .setPositiveButton(R.string.yes, dialogClickListener).show();

        return false;
    });

    expListView.setFastScrollEnabled(true);
    expListView.setAdapter(listAdapter);
}
 
源代码26 项目: Dainty   文件: HistoryListView.java
@Override
public void setAdapter(ExpandableListAdapter adapter) {
    super.setAdapter(adapter);
}
 
源代码27 项目: letv   文件: PullToZoomExpandableListViewEx.java
public void setAdapter(ExpandableListAdapter adapter) {
    ((ExpandableListView) this.mRootView).setAdapter(adapter);
}
 
源代码28 项目: BigApp_Discuz_Android   文件: IphoneTreeView.java
@Override
public void setAdapter(ExpandableListAdapter adapter) {
	super.setAdapter(adapter);
	mAdapter = (IphoneTreeHeaderAdapter) adapter;
}
 
源代码29 项目: BigApp_Discuz_Android   文件: IphoneTreeView.java
public void configureHeaderView(int groupPosition, int childPosition) {
	if (mHeaderView == null || mAdapter == null
			|| ((ExpandableListAdapter) mAdapter).getGroupCount() == 0) {
		return;
	}

	int state = mAdapter.getTreeHeaderState(groupPosition, childPosition);

	switch (state) {
	case IphoneTreeHeaderAdapter.PINNED_HEADER_GONE: {
		mHeaderViewVisible = false;
		break;
	}

	case IphoneTreeHeaderAdapter.PINNED_HEADER_VISIBLE: {
		mAdapter.configureTreeHeader(mHeaderView, groupPosition,
				childPosition, MAX_ALPHA);

		if (mHeaderView.getTop() != 0) {
			mHeaderView.layout(0, 0, mHeaderViewWidth, mHeaderViewHeight);
		}

		mHeaderViewVisible = true;

		break;
	}

	case IphoneTreeHeaderAdapter.PINNED_HEADER_PUSHED_UP: {
		View firstView = getChildAt(0);
		int bottom = firstView.getBottom();

		// intitemHeight = firstView.getHeight();
		int headerHeight = mHeaderView.getHeight();

		int y;

		int alpha;

		if (bottom < headerHeight) {
			y = (bottom - headerHeight);
			alpha = MAX_ALPHA * (headerHeight + y) / headerHeight;
		} else {
			y = 0;
			alpha = MAX_ALPHA;
		}

		mAdapter.configureTreeHeader(mHeaderView, groupPosition,
				childPosition, alpha);

		if (mHeaderView.getTop() != y) {
			mHeaderView.layout(0, y, mHeaderViewWidth, mHeaderViewHeight
					+ y);
		}

		mHeaderViewVisible = true;
		break;
	}
	}
}
 
/**
 * Get the ExpandableListAdapter associated with this activity's ExpandableListView.
 */
public ExpandableListAdapter getExpandableListAdapter() {
	return adapter;
}