Java Code Examples for android.widget.ExpandableListView

The following are top voted examples for showing how to use android.widget.ExpandableListView. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: yyox   File: ExpandedListUtils.java   View source code 7 votes vote down vote up
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();
    params.height += appendHeight;
    listView.setLayoutParams(params);
}
 
Example 2
Project: chromium-for-android-56-debug-video   File: RecentTabsPage.java   View source code 7 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 3
Project: GitHub   File: GoodsListActivity.java   View source code 6 votes vote down vote up
private void initExpandableListView() {
    group = new ArrayList<>();
    child = new ArrayList<>();
    //去掉默认箭头
    listView.setGroupIndicator(null);
    addInfo("全部", new String[]{});
    addInfo("上衣", new String[]{"古风", "和风", "lolita", "日常"});
    addInfo("下装", new String[]{"日常", "泳衣", "汉风", "lolita", "创意T恤"});
    addInfo("外套", new String[]{"汉风", "古风", "lolita", "胖次", "南瓜裤", "日常"});

    // 这里是控制如果列表没有孩子菜单不展开的效果
    listView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
        @Override
        public boolean onGroupClick(ExpandableListView parent,
                                    View v, int groupPosition, long id) {
            if (child.get(groupPosition).isEmpty()) {// isEmpty没有
                return true;
            } else {
                return false;
            }
        }
    });
}
 
Example 4
Project: yyox   File: OrderPackageDetailActivity.java   View source code 6 votes vote down vote up
@Override
public void setUIValue(OrderDetail orderDetailJson) {
    for (int i = 0; i < orderDetailJson.getMerchandiseList().size(); i++) {
        if (orderDetailJson.getMerchandiseList().size() != 1) {
            mExpandableListView.collapseGroup(i);
        } else {
            mExpandableListView.expandGroup(i);
        }
        mExpandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                if (orderDetailJson.getMerchandiseList().size() != 1) {
                    return false;
                } else {
                    return true;
                }
            }
        });
    }
}
 
Example 5
Project: yyox   File: ExpandedListUtils.java   View source code 6 votes vote down vote up
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();
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height -= appendHeight;
    listView.setLayoutParams(params);
}
 
Example 6
Project: TimeTrix   File: FragmentTagNotes.java   View source code 6 votes vote down vote up
@Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated (savedInstanceState);
        ImageButton btnAddNotes = (ImageButton) getActivity ().findViewById (R.id.buttonAddNotesTags);
        btnAddNotes.setOnClickListener (this);
        btnAddNotes.setVisibility (View.INVISIBLE);
//        ListView mListViewTag = (ListView) getActivity().findViewById(R.id.listNotesAll);

        mExpandableListViewTag = (ExpandableListView) getActivity ().findViewById (R.id.expandableListNotesTags);

        mArrayListTagNotes = new ArrayList<> ();
//        customAdapterTagNotes = new CustomAdapter(mArrayListTagNotes, getActivity(),tempString , mHandler);
        mCustomAdapterTags = new CustomAdapterTags (getActivity (), Integer.parseInt (mSectionIndex) + 1);
        mExpandableListViewTag.setTag (R.string.filename, mSectionIndex);
        mExpandableListViewTag.setTag (R.string.list_object, mArrayListTagNotes);
        mExpandableListViewTag.setAdapter (mCustomAdapterTags);
        mExpandableListViewTag.setItemsCanFocus (true);
        registerForContextMenu (mExpandableListViewTag);
        mSectionIndex = String.valueOf (mOnFragmentInteractionListener.getSectionIndex());
        populateListView ();

    }
 
Example 7
Project: ywApplication   File: SearchFragment.java   View source code 6 votes vote down vote up
private void initView(View view) {
    expandableListView = (ExpandableListView) view.findViewById(R.id.search_listview);
    heardView = inflater.inflate(R.layout.search_item_heard_view, expandableListView, false);
    setclickListener(heardView);
    contantsAdapter = new ContantsAdapter(getActivity(), groupImgId, text, datas,numId);
    expandableListView.setAdapter(contantsAdapter);
    expandableListView.addHeaderView(heardView);
    expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
        @Override
        public void onGroupExpand(int groupPosition) {
            for (int i = 0; i <groupImgId.size() ; i++) {
                if (groupPosition !=i) {
                    expandableListView.collapseGroup(i);
                }
            }
        }
    });
}
 
Example 8
Project: AssistantBySDK   File: IntroduceFragment.java   View source code 6 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    inflater=LayoutInflater.from(getActivity());
    listAdapter=new ExpandableListAdapter(getActivity());
    listView.setAdapter(listAdapter);
    listView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {

        @Override
        public void onGroupExpand(int groupPosition) {
            for(int i = 0; i < listAdapter.getGroupCount(); i++){
                if(i != groupPosition && listView.isGroupExpanded(i)){
                    listView.collapseGroup(i);
                }
            }
        }
    });
}
 
Example 9
Project: easyfilemanager   File: RootsFragment.java   View source code 6 votes vote down vote up
public void onCurrentRootChanged() {
    if (mAdapter == null || mList == null) return;

    final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
    for (int i = 0; i < mAdapter.getGroupCount(); i++) {
        for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
            final Object item = mAdapter.getChild(i,j);
            if (item instanceof RootItem) {
                final RootInfo testRoot = ((RootItem) item).root;
                if (Objects.equal(testRoot, root)) {
                    try {
                        long id = ExpandableListView.getPackedPositionForChild(i, j);
                        int index = mList.getFlatListPosition(id);
                        //mList.setSelection(index);
                        mList.setItemChecked(index, true);
                    } catch (Exception e){
                        CrashReportingManager.logException(e);
                    }

                    return;
                }
            }
        }
    }
}
 
Example 10
Project: easyfilemanager   File: RootsFragment.java   View source code 6 votes vote down vote up
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;
    }
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: RecentTabsPage.java   View source code 6 votes vote down vote up
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    // Would prefer to have this context menu view managed internal to RecentTabsGroupView
    // Unfortunately, setting either onCreateContextMenuListener or onLongClickListener
    // disables the native onClick (expand/collapse) behaviour of the group view.
    ExpandableListView.ExpandableListContextMenuInfo info =
            (ExpandableListView.ExpandableListContextMenuInfo) menuInfo;

    int type = ExpandableListView.getPackedPositionType(info.packedPosition);
    int groupPosition = ExpandableListView.getPackedPositionGroup(info.packedPosition);

    if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        mAdapter.getGroup(groupPosition).onCreateContextMenuForGroup(menu, mActivity);
    } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        int childPosition = ExpandableListView.getPackedPositionChild(info.packedPosition);
        mAdapter.getGroup(groupPosition).onCreateContextMenuForChild(childPosition, menu,
                mActivity);
    }
}
 
Example 12
Project: cat-is-a-dog   File: FollowingHabitsFragment.java   View source code 6 votes vote down vote up
/**
 * Instantiate our data sources with firebase and our list adapters / view bindings
 * @param inflater
 * @param container
 * @param savedInstanceState
 * @return
 */
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_following_habits, container, false);

    ExpandableListView followingHabitsView =
            (ExpandableListView) view.findViewById(R.id.following_habits_list);

    String userId = CurrentUser.getInstance().getUserId();

    followingDataSource = new SocialDataSource(userId, SocialDataSource.UserType.FOLLOWING);
    followingDataSource.addObserver(this);
    following = followingDataSource.getSource();

    followingHabitsAdapter = new FollowingHabitsListAdapter(
            getActivity(),
            following,
            followingHabitMap
            );

    followingHabitsView.setAdapter(followingHabitsAdapter);

    return view;
}
 
Example 13
Project: expandableListviewDemo   File: MainActivity.java   View source code 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    listView = (ExpandableListView) findViewById(R.id.expandableListView);
    listView.setGroupIndicator(null);
    /**
     * 初始化数据
     */
    initData();
    adapter = new ExAdapter(this, lines);
    listView.setAdapter(adapter);
    //遍历所有group,将所有项设置成默认展开
    int groupCount = listView.getCount();
    for (int i = 0; i < groupCount; i++) {
        listView.expandGroup(i);
    }
}
 
Example 14
Project: simple-share-android   File: RootsFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                            int childPosition, long id) {
    final BaseActivity activity = BaseActivity.get(RootsFragment.this);
    final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
    if (item instanceof RootItem) {
            int index = parent.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
        parent.setItemChecked(index, true);
        activity.onRootPicked(((RootItem) item).root, true);
        Bundle params = new Bundle();
        params.putString("type", ((RootItem) item).root.title);
        AnalyticsManager.logEvent("navigate", ((RootItem) item).root, params);
    } else if (item instanceof AppItem) {
        activity.onAppPicked(((AppItem) item).info);
    } else {
        throw new IllegalStateException("Unknown root: " + item);
    }
    return false;
}
 
Example 15
Project: letv   File: VipFragment.java   View source code 6 votes vote down vote up
private void setRootView(ChannelHomeBean result, boolean isFromNet) {
    if (result != null) {
        this.mChannelHomeBean = result;
        if (!BaseTypeUtils.isListEmpty(this.mChannelHomeBean.searchWords)) {
            initFooterSearchView(this.mChannelHomeBean.searchWords);
        }
        setFocusView(this.mChannelHomeBean.focus);
        if (this.mChannelHomeBean.isShowTextMark) {
            setVipTipsView();
        }
        initTabView(result);
        finishLoading();
        this.mPullView.setPullToRefreshEnabled(true);
        ((ExpandableListView) this.mPullView.getRefreshableView()).setAdapter(this.mListAdapter);
        this.mListAdapter.setDataList((ExpandableListView) this.mPullView.getRefreshableView(), this.mChannelHomeBean, isFromNet);
    }
}
 
Example 16
Project: simple-share-android   File: RootsFragment.java   View source code 6 votes vote down vote up
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;
    }
}
 
Example 17
Project: Android-BLE-to-Arduino   File: DeviceControlActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(R.id.connection_state);
    mDataField = (TextView) findViewById(R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);

    // ATTENTION: This was auto-generated to implement the App Indexing API.
    // See https://g.co/AppIndexing/AndroidStudio for more information.
    client = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build();
}
 
Example 18
Project: FireFiles   File: RootsFragment.java   View source code 6 votes vote down vote up
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition,
                            int childPosition, long id) {
    final BaseActivity activity = BaseActivity.get(RootsFragment.this);
    final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
    if (item instanceof RootItem) {
            int index = parent.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
        parent.setItemChecked(index, true);
        activity.onRootPicked(((RootItem) item).root, true);
        Bundle params = new Bundle();
        params.putString("type", ((RootItem) item).root.title);
        AnalyticsManager.logEvent("navigate", ((RootItem) item).root, params);
    } else if (item instanceof AppItem) {
        activity.onAppPicked(((AppItem) item).info);
    } else {
        throw new IllegalStateException("Unknown root: " + item);
    }
    return false;
}
 
Example 19
Project: letv   File: ChannelDetailExpandableListAdapter.java   View source code 6 votes vote down vote up
public void setDataList(ExpandableListView listView, ChannelHomeBean homeBean, boolean isFromNet) {
    if (homeBean != null && !BaseTypeUtils.isListEmpty(homeBean.block) && listView != null) {
        this.mList.clear();
        Iterator it = homeBean.block.iterator();
        while (it.hasNext()) {
            HomeBlock block = (HomeBlock) it.next();
            if (block != null && (!BaseTypeUtils.isListEmpty(block.list) || "2".equals(block.contentStyle))) {
                this.mList.add(block);
            }
        }
        this.mIsFromNet = isFromNet;
        if (BaseTypeUtils.getElementFromList(homeBean.block, homeBean.tabIndex) != null) {
            this.mStartRank = 1;
        } else {
            this.mStartRank = 0;
        }
        notifyDataSetChanged();
        for (int i = 0; i < getGroupCount(); i++) {
            listView.expandGroup(i);
        }
        listView.setGroupIndicator(null);
        listView.setOnGroupClickListener(new 1(this));
        this.mIsRehreshVipData = true;
    }
}
 
Example 20
Project: linkedout_procon   File: Profile.java   View source code 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    prefs = getContext().getSharedPreferences(STUDENT_PREFS, 0);

    View view =  inflater.inflate(R.layout.fragment_profile, container, false);

    fillInData(view);

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

    prepareListData();
    listAdapter = new ExpandableListAdapter(view.getContext(), listDataHeader, listDataChild);

    // setting list adapter
    expListView.setAdapter(listAdapter);

    return view;
}
 
Example 21
Project: Huochexing12306   File: A6OrderAty.java   View source code 6 votes vote down vote up
private void initViews() {
	mNavigationIndex = getIntent()
			.getIntExtra(EXTRA_PRE_LOAD_DATA_INDEX, 0);
	llytOperate = (LinearLayout) findViewById(R.id.operate);
	btnCancel = (Button) findViewById(R.id.cancel);
	btnCancel.setOnClickListener(this);
	btnPay = (Button) findViewById(R.id.pay);
	btnPay.setOnClickListener(this);
	tvEmptyView = (TextView) findViewById(R.id.emptyView);
	lvOrders = (ExpandableListView) findViewById(R.id.orders);

	lvOrders.setEmptyView(tvEmptyView);
	LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
	View footerView = inflater.inflate(R.layout.fv_a6_order, null);
	lvOrders.addFooterView(footerView);
	mAdapter = new A6OrderExpandableAdapter(this, mLstODBInfos);
	lvOrders.setAdapter(mAdapter);

	// btnPay.setEnabled(false);
	setPanelGone(true);
}
 
Example 22
Project: exciting-app   File: ExpandableHListPosition.java   View source code 6 votes vote down vote up
static ExpandableHListPosition obtainPosition(long packedPosition) {
    if (packedPosition == ExpandableListView.PACKED_POSITION_VALUE_NULL) {
        return null;
    }
    
    ExpandableHListPosition elp = getRecycledOrCreate();
    elp.groupPos = ExpandableListView.getPackedPositionGroup(packedPosition);
    if (ExpandableListView.getPackedPositionType(packedPosition) ==
            ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        elp.type = CHILD;
        elp.childPos = ExpandableListView.getPackedPositionChild(packedPosition);
    } else {
        elp.type = GROUP;
    }
    return elp;
}
 
Example 23
Project: Android-DFU-App   File: ExpandableListActivity.java   View source code 6 votes vote down vote up
/**
 * Updates the screen state (current list and other views) when the content changes.
 * 
 * @see android.support.v7.app.AppCompatActivity#onContentChanged()
 */
@Override
public void onContentChanged() {
	super.onContentChanged();
	View emptyView = findViewById(R.id.empty);
	mList = (ExpandableListView) findViewById(R.id.list);
	if (mList == null) {
		throw new RuntimeException(
				"Your content must have a ExpandableListView whose id attribute is " +
						"'R.id.list'");
	}
	if (emptyView != null) {
		mList.setEmptyView(emptyView);
	}
	mList.setOnChildClickListener(this);
	mList.setOnGroupExpandListener(this);
	mList.setOnGroupCollapseListener(this);

	if (mFinishedStart) {
		setListAdapter(mAdapter);
	}
	mFinishedStart = true;
}
 
Example 24
Project: igrow-android   File: DeviceControlActivity.java   View source code 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(com.igrow.android.R.layout.gatt_services_characteristics);

    final Intent intent = getIntent();
    mDeviceName = intent.getStringExtra(EXTRAS_DEVICE_NAME);
    mDeviceAddress = intent.getStringExtra(EXTRAS_DEVICE_ADDRESS);

    // Sets up UI references.
    ((TextView) findViewById(com.igrow.android.R.id.device_address)).setText(mDeviceAddress);
    mGattServicesList = (ExpandableListView) findViewById(com.igrow.android.R.id.gatt_services_list);
    mGattServicesList.setOnChildClickListener(servicesListClickListner);
    mConnectionState = (TextView) findViewById(com.igrow.android.R.id.connection_state);
    mDataField = (TextView) findViewById(com.igrow.android.R.id.data_value);

    getActionBar().setTitle(mDeviceName);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    Intent gattServiceIntent = new Intent(this, BluetoothLeService.class);
    bindService(gattServiceIntent, mServiceConnection, BIND_AUTO_CREATE);
}
 
Example 25
Project: simple-share-android   File: RootsFragment.java   View source code 6 votes vote down vote up
public void onCurrentRootChanged() {
    if (mAdapter == null || mList == null) return;

    final RootInfo root = ((BaseActivity) getActivity()).getCurrentRoot();
    for (int i = 0; i < mAdapter.getGroupCount(); i++) {
        for (int j = 0; j < mAdapter.getChildrenCount(i); j++) {
            final Object item = mAdapter.getChild(i,j);
            if (item instanceof RootItem) {
                final RootInfo testRoot = ((RootItem) item).root;
                if (Objects.equal(testRoot, root)) {
                    try {
                        long id = ExpandableListView.getPackedPositionForChild(i, j);
                        int index = mList.getFlatListPosition(id);
                        //mList.setSelection(index);
                        mList.setItemChecked(index, true);
                    } catch (Exception e){
                        CrashReportingManager.logException(e);
                    }

                    return;
                }
            }
        }
    }
}
 
Example 26
Project: CIA   File: ViewHabitIntentTests.java   View source code 5 votes vote down vote up
/**
 * Select the first habit in the user's list
 * @return the name of the first habit
 */
private String loadHabit(){
    // expand the first category
    solo.clickOnView(((ExpandableListView)solo.getView(R.id.HabitTypeExpandableListView)).getAdapter().getView(0, null, null));
    solo.sleep(600);

    String habitName = (String) ((ExpandableListView)solo.getView(R.id.HabitTypeExpandableListView)).getAdapter().getItem(1);

    // click in the first habit in the category
    solo.clickInList(2, 0);
    solo.sleep(1500);

    solo.assertCurrentActivity("wrong activity", HabitViewActivity.class);
    return habitName;
}
 
Example 27
Project: ultrasonic   File: PullToRefreshExpandableListView.java   View source code 5 votes vote down vote up
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
	final ExpandableListView lv;
	if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
		lv = new InternalExpandableListViewSDK9(context, attrs);
	} else {
		lv = new InternalExpandableListView(context, attrs);
	}

	// Set it to this so it can be used in ListActivity/ListFragment
	lv.setId(android.R.id.list);
	return lv;
}
 
Example 28
Project: CustomListView   File: PullToRefreshExpandableListView.java   View source code 5 votes vote down vote up
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
	final ExpandableListView lv;
	if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
		lv = new InternalExpandableListViewSDK9(context, attrs);
	} else {
		lv = new InternalExpandableListView(context, attrs);
	}

	// Set it to this so it can be used in ListActivity/ListFragment
	lv.setId(android.R.id.list);
	return lv;
}
 
Example 29
Project: ywApplication   File: PullToRefreshExpandableListView.java   View source code 5 votes vote down vote up
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
	final ExpandableListView lv;
	if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
		lv = new InternalExpandableListViewSDK9(context, attrs);
	} else {
		lv = new InternalExpandableListView(context, attrs);
	}

	// Set it to this so it can be used in ListActivity/ListFragment
	lv.setId(android.R.id.list);
	return lv;
}
 
Example 30
Project: CSipSimple   File: WizardChooser.java   View source code 5 votes vote down vote up
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
	Map<String, Object> data = childDatas.get(groupPosition).get(childPosition);
	String wizard_id = (String) data.get(WizardUtils.ID);
	
	Intent result = getIntent();
	result.putExtra(WizardUtils.ID, wizard_id);
	
	setResult(RESULT_OK, result);
	finish();

	return true;
}
 
Example 31
Project: homebank_android   File: BudgetSummaryFragment.java   View source code 5 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.category_list, container, false);
    expandableListView = (ExpandableListView) rootView.findViewById(R.id.expandable_category_list);
    addOnClickListeners();
    listAdapter = new ExpandableCategoryAdapter(
            getActivity(),
            HomeActivity.xhb.getTopCategoriesForMonthlyBudget(HomeActivity.CURRENT_MONTH),
            HomeActivity.CURRENT_MONTH
    );
    expandableListView.setAdapter(listAdapter);
    return rootView;
}
 
Example 32
Project: easyfilemanager   File: RootsFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
 
Example 33
Project: simple-share-android   File: RootsFragment.java   View source code 5 votes vote down vote up
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);
            }
        }
    }
}
 
Example 34
Project: easyfilemanager   File: RootsFragment.java   View source code 5 votes vote down vote up
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
    int itemType = ExpandableListView.getPackedPositionType(id);
    int childPosition;
    int groupPosition;

    if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
        childPosition = ExpandableListView.getPackedPositionChild(id);
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        final Item item = (Item) mAdapter.getChild(groupPosition, childPosition);
        if (item instanceof AppItem) {
            showAppDetails(((AppItem) item).info);
            return true;
        } else if (item instanceof BookmarkItem) {
            removeBookark((BookmarkItem)item);
            return true;
        }  else {
            return false;
        }

    } else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
        groupPosition = ExpandableListView.getPackedPositionGroup(id);
        return false;

    } else {
        return false;
    }
}
 
Example 35
Project: easyfilemanager   File: RootsFragment.java   View source code 5 votes vote down vote up
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);
            }
        }
    }
}
 
Example 36
Project: Hotspot-master-devp   File: PullToRefreshExpandableListView.java   View source code 5 votes vote down vote up
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
	final ExpandableListView lv;
	if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
		lv = new InternalExpandableListViewSDK9(context, attrs);
	} else {
		lv = new InternalExpandableListView(context, attrs);
	}

	// Set it to this so it can be used in ListActivity/ListFragment
	lv.setId(android.R.id.list);
	return lv;
}
 
Example 37
Project: NoticeDog   File: InboxCursorAdapter.java   View source code 5 votes vote down vote up
private InboxCursorAdapter(Context context, Cursor cursor, final ExpandableListView parent) {
    super(cursor, context);
    GuiceModule.get().injectMembers(this);
    this.context = context;
    this.parent = parent;
    SwipeDismissListViewTouchListener touchListener = new SwipeDismissListViewTouchListener(parent, new SwipeDismissListViewTouchListener.DismissCallbacks() {
        public boolean canDismiss(int position) {
            return true;
        }

        public void onDismiss(ListView listView, int[] reverseSortedPositions) {
            for (int reverseSortedPosition : reverseSortedPositions) {
                long packedPosition = parent.getExpandableListPosition(reverseSortedPosition);
                int type = ExpandableListView.getPackedPositionType(packedPosition);
                int groupPosition;
                if (type == 1) {
                    groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
                    int childPosition = ExpandableListView.getPackedPositionChild(packedPosition);
                    Log.d(InboxCursorAdapter.TAG, "Removing group = " + groupPosition + "  |  child = " + childPosition + "  |  global position = " + reverseSortedPosition);
                    InboxCursorAdapter.this.inboxManager.deleteMessage(InboxCursorAdapter.this.inboxManager.getMessageFromViewCursor(InboxCursorAdapter.this.getChild(groupPosition, childPosition)));
                    InboxCursorAdapter.this.reset();
                } else if (type == 0) {
                    groupPosition = ExpandableListView.getPackedPositionGroup(packedPosition);
                    Log.d(InboxCursorAdapter.TAG, "Removing group = " + groupPosition + "  |  global position = " + reverseSortedPosition);
                    InboxCursorAdapter.this.inboxManager.deleteConversation(InboxCursorAdapter.this.inboxManager.getConversationFromViewCursor(InboxCursorAdapter.this.getGroup(groupPosition)));
                    InboxCursorAdapter.this.reset();
                }
            }
        }
    });
    touchListener.setSwipeToDismissViewResourceId(R.id.swipe_to_dismiss_view);
    parent.setOnTouchListener(touchListener);
    parent.setOnScrollListener(touchListener.makeScrollListener());
    parent.setSelector(17170445);
}
 
Example 38
Project: CustomAndroidOneSheeld   File: PullToRefreshExpandableListView.java   View source code 5 votes vote down vote up
@Override
protected ExpandableListView createRefreshableView(Context context, AttributeSet attrs) {
	final ExpandableListView lv;
	if (VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD) {
		lv = new InternalExpandableListViewSDK9(context, attrs);
	} else {
		lv = new InternalExpandableListView(context, attrs);
	}

	// Set it to this so it can be used in ListActivity/ListFragment
	lv.setId(android.R.id.list);
	return lv;
}
 
Example 39
Project: simple-share-android   File: RootsFragment.java   View source code 5 votes vote down vote up
@Override
public View onCreateView(
        LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    final View view = inflater.inflate(R.layout.fragment_roots, container, false);
    mList = (ExpandableListView) view.findViewById(android.R.id.list);
    mList.setOnChildClickListener(mItemListener);
    mList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);

    DisplayMetrics metrics = new DisplayMetrics();
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
    int width = Utils.dpToPx(302);

    boolean rtl = Utils.isRTL();
    int leftPadding = rtl ? 10 : 50;
    int rightPadding = rtl ? 50 : 10;
    int leftWidth = width - Utils.dpToPx(leftPadding);
    int rightWidth = width - Utils.dpToPx(rightPadding);

    if(Utils.hasJellyBeanMR2()){
        mList.setIndicatorBoundsRelative(leftWidth, rightWidth);

    } else {
        mList.setIndicatorBounds(leftWidth, rightWidth);
    }
    return view;
}
 
Example 40
Project: Veggietizer   File: Popup.java   View source code 5 votes vote down vote up
/**
 * Shows the popup that is opened when the user clicks on the info action button of a details page.
 * An {@link ExpandableListView} is used as a layout.
 *
 * @param context The context to show the popup in.
 * @param title The popup's title.
 * @param groups The expandable categories.
 * @param entries Each category in <code>groups</code> shows one entry when expanded.
 * @return The dialog.
 */
private static AlertDialog showDetailsInfo(Context context, String title,
                                           String[] groups, String[] entries,
                                           DialogInterface.OnClickListener onSubmitListener) {
    if (groups.length != entries.length) {
        throw new IllegalArgumentException();
    }

    // Custom title
    TextView customTitle = (TextView) LayoutInflater.from(context).inflate(R.layout.popup_title, null);
    customTitle.setText(title);

    View popupDetailsInfo = LayoutInflater.from(context)
            .inflate(R.layout.popup_details_info, null);
    ExpandableListView listViewDetailsInfo = (ExpandableListView)
            popupDetailsInfo.findViewById(R.id.expandablelistview_popup_details_info);
    ExpandableListAdapter adapter = createDetailsInfoAdapter(context, groups, entries);
    listViewDetailsInfo.setAdapter(adapter);

    AlertDialog.Builder popupBuilder = new AlertDialog.Builder(context);
    popupBuilder.setView(popupDetailsInfo)
            .setNeutralButton(R.string.ok, onSubmitListener)
            .setCustomTitle(customTitle);

    AlertDialog dialog = popupBuilder.create();
    dialog.show();

    Utility.setFont(FontManager.Font.ROBOTO_LIGHT, new TextView[]{
            customTitle
    });

    return dialog;
}