Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8742029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:25:40+00:00 2026-06-13T11:25:40+00:00

I’m trying to make a simple tasklist in Android using Eclipse. The layout i’m

  • 0

I’m trying to make a simple tasklist in Android using Eclipse. The layout i’m trying to build is this:

Layout

I want the tasks to be the groups, and under each task, 2 childs with task description and task’s limit date.

At the right side of the task/group, I wanted a checkbox for marking tasks as done, but I don’t really know how to do that. I even have problems using adapters for my ExpandableListView (all questions I manage to find talk about creating ExpandableListView from scrap using ListViews & Maps of Strings, but I want to use an already created ExpandableListView in my XML layout, if that’s possible) or thinking how I’m going to add tasks from the input (the input is an AlertDialog appearing when you press the button).

Any ideas will be appreciated, and sorry for my English (not my mother language).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T11:25:41+00:00Added an answer on June 13, 2026 at 11:25 am

    The way i’d do something like this is to make your expandable listview utilizing a custom adapter (these extend the baseexpandableadapter class). Then you have the ability to inflate or create different views for your group and child views. This is an example of how you might set it up if you’re using an expandable listactivity (vs regular activity with expandable listview):

    public class ExpandableList1 extends ExpandableListActivity {
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
        // Set up our adapter
        ExpandableListAdapter mAdapter = new MyExpandableListAdapter(this);
        setListAdapter(mAdapter);
    }
        // The custom adapter part
    public class MyExpandableListAdapter extends BaseExpandableListAdapter {
        // Sample data set.  children[i] contains the children (String[]) for groups[i].
        private String[] groups = { "Task1", "Task2", "Task3", "Task4"};
        private String[][] children = {
                { "Task Description", "Task time limit date" },
                { "Task Description", "Task time limit date" },
                { "Task Description", "Task time limit date" },
                { "Task Description", "Task time limit date" }
        };
    
    public MyExpandableListAdapter(Context context) {
        super();
        this.context = context;
    }
    
    private Context context;
    
    static class ViewHolder {
            TextView text;
            CheckBox checkbox;
        }
    
        public Object getChild(int groupPosition, int childPosition) {
            return children[groupPosition][childPosition];
        }
    
        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;
        }
    
        public int getChildrenCount(int groupPosition) {
            return children[groupPosition].length;
        }
    
        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
        return convertView;
        }
    
        public Object getGroup(int groupPosition) {
            return groups[groupPosition];
        }
    
        public int getGroupCount() {
            return groups.length;
        }
    
        public long getGroupId(int groupPosition) {
            return groupPosition;
        }
    
        public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
                ViewGroup parent) {
    
        final ViewHolder holder;
    
            if (convertView == null) {
                LayoutInflater viewInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                convertView = viewInflater.inflate(R.layout.mtopics_groupview, parent, false);
                holder = new ViewHolder();
                holder.text = (TextView)convertView.findViewById(R.id.mtopicsgrouptv);
                holder.checkbox = (CheckBox)convertView.findViewById(R.id.cb_group);
    
                convertView.setTag(holder);
            } else {
                holder = (ViewHolder) convertView.getTag();
            }
    
        holder.text.setText(getGroup(groupPosition).toString());
        return convertView;
        }
    
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }
    
        public boolean hasStableIds() {
            return true;
        }
    
    }
    

    You have the ability to create your group views and child views programatically or to you can inflate these from xml. In my example, i’ve inflated from xml for just the group view as it is far easier for more complex views. I know that pattern seems like a round-about method for the use of the two line inflate code, but it will help the performance of your view tremendously. You can learn more about it here: http://www.youtube.com/watch?v=wDBM6wVEO70. As for now, the xml is pretty simple, it’s just a textview and a checkbox. (small hint: checkboxes in groupviews must have “focusable” set to false AND can’t be directly adjacent the group view indicator, or the group view won’t be able to expand)

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
    
        <CheckBox
            android:id="@+id/cb_group"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:checked="true"
            android:focusable="false" />
    
        <TextView
            android:id="@+id/mtopicsgrouptv"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:layout_marginLeft="40dp"
            android:focusable="false"
            android:text="Small Text"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    
    </RelativeLayout>   
    

    I didn’t do the childview, but depending on what you want to do with it, you can model it after the group view. you can just put a textview in there and set the text based of the child position. BUT i gotta warn you, as of now you’ll quickly find that your checkbox states are gonna be wacky whenever you click them. sometimes the check will move or dissapear or not work at all. If you wanna know why i could tell you, but i’ll just post the solution for now. You have to set up an arraylist or map or anything really to hold the checkbox states and then load them (since their positions will correspond). Here is how i’d do it in my getGroupView portion.

    // make the list
    ArrayList<Boolean> group_check_states = new ArrayList<Boolean> (groups.length);
            for(int i = 0; i < groups.length; i++) {
            group_check_states.add(true);
        }
    // load the checkstates
        if ((group_check_states.get(groupPosition)) == true) {
            holder.checkbox.setChecked(true);
        } else {
            holder.checkbox.setChecked(false);
        }
    
    //   save the checkstates
    holder.checkbox.setOnClickListener(new OnClickListener() {
    
            public void onClick(View v) {
                if (holder.checkbox.isChecked()) {
                    group_check_states.set(groupPosition, true);
                } else {
                    group_check_states.set(groupPosition, false);
                    }
                }
        });
    

    You can also put your checkbox action code in there, too. Now the adapter looks the part, but it might be too simple for what you intend. you want to be able to set the tasks dynamically based on what was inputted your alert dialog. In that case, you wouldn’t want to be using that simply array I that used (groups and children), you might want to load from an arraylist, or other type of list that you can dynamically add and remove things dynamically, which would be modified by your alert dialog.

    i hope it helped, but i’m sure there’ll be some more issues along the way. just holla if somethings comes up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.