Java Code Examples for android.widget.ExpandableListView.setOnChildClickListener()

The following are Jave code examples for showing how to use setOnChildClickListener() of the android.widget.ExpandableListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: RecentTabsPage.java   Source Code and License Vote up 7 votes
/**
 * 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 2
Project: Android-DFU-App   File: ExpandableListActivity.java   Source Code and License Vote up 6 votes
/**
 * 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 3
Project: igrow-android   File: DeviceControlActivity.java   Source Code and License Vote up 6 votes
@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 4
Project: Android-BLE-to-Arduino   File: DeviceControlActivity.java   Source Code and License Vote up 6 votes
@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 5
Project: easyfilemanager   File: RootsFragment.java   Source Code and License Vote up 5 votes
@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 6
Project: FireFiles   File: RootsFragment.java   Source Code and License Vote up 5 votes
@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 7
Project: simple-share-android   File: RootsFragment.java   Source Code and License Vote up 5 votes
@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 8
Project: CIA   File: HabitsFragment.java   Source Code and License Vote up 4 votes
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    user = (Profile) getArguments().getSerializable(ID_PROFILE);
    noHabits = (TextView) view.findViewById(R.id.noHabits);
    if (user.hasValidId())
        user.load();

    if (user.getHabits().size() > 0) {
        noHabits.setVisibility(View.GONE);
    }

    user.synchronize();

    // handle any habits that may have been missed since the user's last login
    Date currentDate = new Date();
    if (user.getLastLogin() != null && !DateUtilities.isSameDay(user.getLastLogin(), currentDate)) {
        GregorianCalendar calendar = new GregorianCalendar();
        calendar.setTime(user.getLastLogin());

        // go through each date between the user's last login and the current date
        while (!DateUtilities.isSameDay(calendar.getTime(), currentDate)){
            // update all events at the end of that date, to make sure they are marked as missed if they weren't completed
            // on that day
            user.onDayEnd(calendar.getTime());
            calendar.add(Calendar.DATE, 1);
        }
    }

    user.setLastLogin(currentDate);
    user.save();

    // initialize the list displaying all habits the user has
    expandableListView = (ExpandableListView) view.findViewById(R.id.HabitTypeExpandableListView);
    adapter = new ExpandableListViewAdapter(getContext(), user);
    expandableListView.setAdapter(adapter);

    expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int group, int child, long childRowId) {

            String category = SetUtilities.getItemAtIndex(user.getHabitCategories(), group);
            Habit habit = user.getHabitsInCategory(category).get(child);

            ArrayList<String> types = new ArrayList<>();
            types.addAll(user.getHabitCategories());

            startDetailsActivity(habit, types);

            return false;
        }
    });

}