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

  • SEARCH
  • Home
  • 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 8364087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:20:54+00:00 2026-06-09T12:20:54+00:00

public class Official_Activity extends Activity{ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.official_data2); setupViewComponent(); new

  • 0
    public class Official_Activity extends Activity{
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.official_data2);
    setupViewComponent();

    new setList().execute();
}

 private void setupViewComponent() {
    // TODO Auto-generated method stub
     ExpandableListView list = (ExpandableListView)findViewById(R.id.list);
}

private class setList extends AsyncTask <Void, Void, List<News>>{

    List<Map<String, Object>> groups;
    List<List<HashMap<String, Object>>> childs;




     final ProgressDialog progDlg3 = new ProgressDialog(Official_Group.group);


    protected void onPreExecute() {
        // TODO Auto-generated method stub
        super.onPreExecute();
        progDlg3.setTitle("Please wait");
        progDlg3.setMessage("Loading...");
        progDlg3.setIcon(android.R.drawable.ic_dialog_info);
        progDlg3.setCancelable(false);
        progDlg3.show();
    }

    @Override
    protected List<News> doInBackground(Void... arg0) {
        // TODO Auto-generated method stub
        List<News> newes = null;
        try {
            newes = GetJson.update();
            return newes;
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return newes;


    }

    protected void onPostExecute(List<News> result){

         groups = new ArrayList<Map<String, Object>>();
        Map<String, Object> group1 = new HashMap<String, Object>();
        group1.put("ItemTitle", "Earthquake report");
        group1.put("ItemText", "Data from USGS");
        Map<String, Object> group2 = new HashMap<String, Object>();
        group2.put("ItemTitle", "Weather info");
        group2.put("ItemText", "Show weather info");
    groups.add(group1);
    groups.add(group2);

    List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
    for(News news : result){
        HashMap<String, Object> item = new HashMap<String, Object>();
        item.put("ItemTitle", news.getPlace());
        item.put("ItemText", "Magnitude: "+news.getMag());
        item.put("latit", news.getLatit());
        item.put("longit", news.getLongit());
        item.put("date", news.getTime());
        item.put("tzone", news.getTzone());
        data.add(item);
    }

List<HashMap<String, Object>> weather = new ArrayList<HashMap<String, Object>>();
    HashMap<String, Object> item2 = new HashMap<String, Object>();
    item2.put("ItemTitle", "Coming Soon");
    item2.put("ItemText", "");
    item2.put("latit", "");
    item2.put("longit", "");
    item2.put("date", "");
    item2.put("tzone", "");
    weather.add(item2);

     childs = new ArrayList<List<HashMap<String, Object>>>();
    childs.add(data);
    childs.add(weather);

    ExpandableListAdapter mExpaListAdap = new SimpleExpandableListAdapter(
            this,
            groups,
            R.layout.list_item,
            new String[] {"ItemTitle", "ItemText"},                   
            new int[] {R.id.ItemTitle, R.id.ItemText},
            childs,                                     
            R.layout.list_earthquake,
            new String[] {"ItemTitle", "ItemText", "latit", "longit", "date", "tzone"},
            new int[] {R.id.ItemTitle, R.id.ItemText, R.id.latit, R.id.longit, R.id.date, R.id.tzone}
            );

        list.setAdapter(mExpaListAdap);
      progDlg3.dismiss();     
    }



 }
   }

But error was found:

The constructor SimpleExpandableListAdapter(Official_Activity.setList,
List<Map<String,Object>>, int, String[], int[], List<List<HashMap<String,Object>>>,
int, String[], int[]) is undefined

How can it be solved?

code of getJson: Intent with ListView (JSON data)

9/8 update:
After I’ve change “this” to “Official_Activity.this”, another error is found:

08-08 09:34:33.975: E/AndroidRuntime(335): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.abc/com.android.abc.Official_Activity}: java.lang.NullPointerException

Is there any bugs in the code?

  • 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-09T12:20:56+00:00Added an answer on June 9, 2026 at 12:20 pm

    You are in an innerclass, so “this” is Official_Activity.setList class, which is not a context, you have to write Official_Activity.this instead, like the following:

    new SimpleExpandableListAdapter(
                Official_Activity.this,
                groups,
                R.layout.list_item,
                new String[] {"ItemTitle", "ItemText"},                   
                new int[] {R.id.ItemTitle, R.id.ItemText},
                childs,                                     
                R.layout.list_earthquake,
                new String[] {"ItemTitle", "ItemText", "latit", "longit", "date", "tzone"},
                new int[] {R.id.ItemTitle, R.id.ItemText, R.id.latit, R.id.longit, R.id.date, R.id.tzone}
                );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

public class tryAnimActivity extends Activity { /** * The thread to process splash screen
public class Test { public static void main(String[] args) { DemoAbstractClass abstractClass = new
public class HttpPostTask extends AsyncTask<Void, Integer, Void> { TextView txtStatus = (TextView)findViewById(R.id.txtStatus); @Override protected
public class WeeklyInspection : Activity { WebView view = (WebView) FindViewById(Resource.Id.inspectionWV); view.Settings.JavaScriptEnabled = true;
public class MyClass { public string MyProperty{ get; set; } Now, I would like
public class Test1<Type> { public Type getCompositeMessage(Type... strings) { Type val = (Type) ;
public class Knowing { static final long tooth = 343L; static long doIT(long tooth)
public class A { private A(int param1, String param2) {} public static A createFromCursor(Cursor
public class User { public long Id {get;set;} [References(typeof(City))] public long CityId {get;set;} [????]
public class LinkedList { Object contents; LinkedList next = null; public boolean equals(Object item)

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.