Android Open Source - garageoPIner-androidApp Expandable List Adapter

From Project

Back to project page garageoPIner-androidApp.


The source code is released under:

Apache License

If you think the Android project garageoPIner-androidApp listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.wirthual.garageopiner.utils;
/*  ww  w.j a  va  2  s .  c  o m*/
import java.util.HashMap;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.TimePicker;

import com.wirthual.garageopiner.R;

public class ExpandableListAdapter extends BaseExpandableListAdapter implements android.view.View.OnClickListener {

  private Activity context;
    private Map<String, String[]> week;
    String[] days;

    public ExpandableListAdapter(Activity context) {
        this.context = context; 
        week = new HashMap<String, String[]>();
    public Object getChild(int groupPosition, int childPosition) {
        return week.get("Montag")[childPosition];
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    public View getChildView(final int groupPosition, final int childPosition,
            boolean isLastChild, View convertView, ViewGroup parent) {
        final String time = (String) getChild(groupPosition, childPosition);
        LayoutInflater inflater = context.getLayoutInflater();
        if (convertView == null) {
            convertView = inflater.inflate(com.wirthual.garageopiner.R.layout.expandlist_child, null);
        String text;
        TextView hinoderweg = (TextView)convertView.findViewById(;
        if(childPosition == 0){
          text = context.getResources().getString(R.string.weg);
          text = context.getResources().getString(R.string.hin);
        TextView timeweg = (TextView) convertView.findViewById(;
        TextView timehin = (TextView) convertView.findViewById(;
        Switch enable = (Switch) convertView.findViewById(;

        return convertView;
    public int getChildrenCount(int groupPosition) {
        return 2;
    public Object getGroup(int groupPosition) {
        return week.get(groupPosition);
    public int getGroupCount() {
        return week.size();
    public long getGroupId(int groupPosition) {
        return groupPosition;
    public View getGroupView(int groupPosition, boolean isExpanded,
            View convertView, ViewGroup parent) {
        String day = days[groupPosition];
        if (convertView == null) {
            LayoutInflater infalInflater = (LayoutInflater) context
            convertView = infalInflater.inflate(com.wirthual.garageopiner.R.layout.expandlist_parent,
        TextView item = (TextView) convertView.findViewById(;
        item.setTypeface(null, Typeface.BOLD);
        return convertView;
    public boolean hasStableIds() {
        return true;
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return true;
    private void initMap(){
      days = context.getResources().getStringArray(com.wirthual.garageopiner.R.array.days);
      String[] time = {"0.00","0.00"};
      for (int i = 0; i < 7; i++) {

  public void onClick(final View v) {
    TimePickerDialog tpd = new TimePickerDialog(context,
            new TimePickerDialog.OnTimeSetListener() {
                public void onTimeSet(TimePicker view, int hourOfDay,
                        int minute) {
                      ((TextView)v).setText(String.format("%02d",hourOfDay) + ":" + String.format("%02d",minute));
            }, 8, 0, true);;



Java Source Code List