1. PopCole's Avatar
    Hi. I'm new in Android development (I'm not that bad in networking, web development, c sharp.. but here Im big noob). As my first task (after spending some time with books) I decided to make Class Schedule fore my daughter. So, I end up with huge problems with ListView (simple_expandable_list_item_1). Finally, I found some code online and (in the last few days) I'm trying to make it work. Probably I messed up a lot, but I really hope that someone can help.

    ListViewID is raspView

    I put code in Notepad file because I can't post it in here
    Attached Files
    09-05-2015 09:00 AM
  2. Golfdriver97's Avatar
    Welcome to the forums. Programming and development is somewhat outside the scope of this forum. There may be some people here who can help, but the question will be if they see it.

    I will post the code for you and then delete the attachment.
    09-05-2015 09:39 AM
  3. Golfdriver97's Avatar
    Here is the lines of code:

    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.widget.SimpleExpandableListAdapter;
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.AdapterView;
    import android.widget.ArrayAdapter;
    import android.widget.ListAdapter;
    import android.widget.ListView;
    import android.widget.Toast;
    import android.widget.SimpleCursorTreeAdapter;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;

    public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    //Prvi Deo
    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>() {{
    add(new HashMap<String, String>() {{
    put("ROOT_NAME", "Group 1");
    }});
    add(new HashMap<String, String>() {{
    put("ROOT_NAME", "Group 2");
    }});
    }};

    List<List<Map<String, String>>> listOfChildGroups = new ArrayList<List<Map<String, String>>>();

    List<Map<String, String>> childGroupForFirstGroupRow = new ArrayList<Map<String, String>>(){{
    add(new HashMap<String, String>() {{
    put("CHILD_NAME", "child in group 1");
    }});
    add(new HashMap<String, String>() {{
    put("CHILD_NAME", "child in group 1");
    }});
    }};
    listOfChildGroups.add(childGroupForFirstGroupRow);

    List<Map<String, String>> childGroupForSecondGroupRow = new ArrayList<Map<String, String>>(){{
    add(new HashMap<String, String>() {{
    put("CHILD_NAME", "child in group 2");
    }});
    add(new HashMap<String, String>() {{
    put("CHILD_NAME", "child in group 2");
    }});
    }};
    listOfChildGroups.add(childGroupForSecondGroupRow);


    //Drugi Deo
    new SimpleExpandableListAdapter(
    this,
    groupData,
    android.R.layout.simple_expandable_list_item_1,
    new String[] { "ROOT_NAME" },
    new int[] { android.R.id.text1 },

    listOfChildGroups,
    android.R.layout.simple_expandable_list_item_2,
    new String[] { "CHILD_NAME", "CHILD_NAME" },
    new int[] { android.R.id.text1, android.R.id.text2 }

    );

    ListAdapter casAdapter = new ArrayAdapter<String>(this, android.R.layout.expandable_list_content);

    ListView raspView = (ListView) findViewById(R.id.raspView);
    raspView.setAdapter(casAdapter);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
    return true;
    }

    return super.onOptionsItemSelected(item);
    }
    }
    09-05-2015 09:39 AM

Similar Threads

  1. People having issues with Gmail notifications
    By carraser891 in forum Samsung Galaxy Note 5
    Replies: 3
    Last Post: 09-05-2015, 07:12 PM
  2. Replies: 2
    Last Post: 09-05-2015, 10:09 AM
  3. Android Music Player Will Not Read Music Any More. Help.
    By tavis7g in forum Android 4.1 / 4.2 / 4.3 Jelly Bean
    Replies: 1
    Last Post: 09-05-2015, 09:17 AM
  4. Does anyone else have this problem?
    By AC Question in forum Ask a Question
    Replies: 0
    Last Post: 09-05-2015, 07:33 AM
  5. Replies: 0
    Last Post: 09-05-2015, 07:19 AM
LINK TO POST COPIED TO CLIPBOARD