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 8468881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:04:06+00:00 2026-06-10T16:04:06+00:00

I already extended SherlockMapActivity,which is a compatibilty library that allows tabbed like interface found

  • 0

I already extended SherlockMapActivity,which is a compatibilty library that allows tabbed like interface found in later versions of android.. The Problem is I have two Tabs. A Mapview Tab and a ListView Tab.The MapView works fine but the List View doesnt.I want a way to implement an expandablelistview without extending the expandablelistactivity..The Expandablelistview should appear under the listview tab.
The problem now is that the setListAdapter method is undefined in my Code..pls help.

public class MainActivity extends SherlockMapActivity implements LocationListener,ActionBar.TabListener {

private MapController mapController;
private MapView mapView;    
private LocationManager locationManager;
private GeoPoint currentPoint;
private Location currentLocation = null;
private PlaceOverlay currPos;
private ViewSwitcher tswitcher;

public boolean showMiniHelp = true;

TableLayout tlayout;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    setContentView(R.layout.activity_main);

    tswitcher = (ViewSwitcher)findViewById(R.id.viewSwitcher1);


    getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.Tab tab1 = getSupportActionBar().newTab();
    tab1.setText("Map View");
    tab1.setTabListener(this);
    getSupportActionBar().addTab(tab1);

    ActionBar.Tab tab2 = getSupportActionBar().newTab();
    tab2.setText("List View");
    tab2.setTabListener(this);
    getSupportActionBar().addTab(tab2);


    mapView = (MapView)findViewById(R.id.mapView);
    mapView.setBuiltInZoomControls(true);
    mapView.setSatellite(false);      
    mapController = mapView.getController();
    mapController.setZoom(17);
    getLastLocation();
    drawCurrPositionOverlay();
    drawStores();
    drawSportLocations();
    animateToCurrentLocation();

    //ListViewSetup

     // Construct Expandable List
    final String NAME = "name";
    final String IMAGE = "image";
    final String DATA = "data";
    final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>();

    final HashMap<String, String> group1 = new HashMap<String, String>();
    group1.put(NAME, "Group 1");
    headerData.add( group1 );

    final HashMap<String, String> group2 = new HashMap<String, String>();
    group2.put(NAME, "Group 2");
    headerData.add( group2);

    final HashMap<String, String> group3 = new HashMap<String, String>();
    group3.put(NAME, "Group 3");
    headerData.add( group3);

    final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>();

    final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>();
    childData.add(group1data);

    final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>();
    childData.add(group2data);

    final ArrayList<HashMap<String, Object>> group3data = new ArrayList<HashMap<String, Object>>();
    childData.add(group3data);

    // Set up some sample data in both groups
    for( int i=0; i<10; ++i) {
        final HashMap<String, Object> map = new HashMap<String,Object>();
        map.put(NAME, "Child " + i );
        map.put(DATA, "Data " + i);
        map.put(IMAGE, getResources().getDrawable((i%3==0? R.drawable.basketball : R.drawable.supermarket)));
        ( i%2==0 ? group1data : group2data ).add(map);
    }
    final HashMap<String, Object> map = new HashMap<String,Object>();
    map.put(NAME, "Child x");
    map.put(DATA, "Data x");
    map.put(IMAGE, getResources().getDrawable(R.drawable.tennis));
    group3data.add(map);

    setListAdapter( new SimpleExpandableListAdapter(
            this,
            headerData,
            R.layout.group_row,
            new String[] { NAME, DATA },    // the names of the data
            new int[] { R.id.groupname },   // the text field to populate with the field data
            childData,
            0,
            null,
            new int[] {}
        ) {
            @Override
            public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
                final View v = super.getChildView(groupPosition, childPosition, isLastChild, convertView, parent);

                // Populate your custom view here
                ((TextView)v.findViewById(R.id.name)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(NAME) );
                ((TextView)v.findViewById(R.id.data)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(DATA) );
                ((ImageView)v.findViewById(R.id.image)).setImageDrawable( (Drawable) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(IMAGE) );

                return v;
            }

            @Override
            public View newChildView(boolean isLastChild, ViewGroup parent) {
                 return layoutInflater.inflate(R.layout.expandable_list_item_with_image, null, false);
            }
        }
    );
    ExpandableListView list = (ExpandableListView) findViewById(android.R.id.list);
    list.setOnChildClickListener(new OnChildClickListener(){
        public boolean onChildClick(ExpandableListView parent, View v,
                int groupPosition, int childPosition, long id) {
            System.out.println("Group:"+groupPosition+", Child: "+childPosition);
            return true;
        }
    });
  • 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-10T16:04:07+00:00Added an answer on June 10, 2026 at 4:04 pm

    Absolutely it is! Even I had a similar problem.

    Extending ExpandableListActivity just helps you by directly giving you the adapters and stuff.

    But you can also define an ExpandableListView in your layout and declare all it’s adapters manually.

    This tutorial will help you.

    Good luck!

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

Sidebar

Related Questions

I already know that many information requires extended permissions to be accessed by the
Already found this page with some helpful hints. Problem is I need to debug
I already asked this question but at that time I tought that the refresh
i already have a project with TreeNode class which creates a hierachy of nodes
I already asked a question here : combining-2-extended-activity-for-sms-notification And now i get a new
I have extended the android View class, and now I want to define a
I'm writing an application in C that can be extended at runtime by means
a usual connection string would look like Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\file.csv;Extended Properties=text;HDR=Yes;FMT=Delimited; but i need a
Is there an already written Java DNS Server that only implements authoritative responses. I
I have a Subsonic3 Active Record generated partial User class which I've extended on

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.