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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:34:17+00:00 2026-06-09T23:34:17+00:00

I have do this simple app, in this app when I click on start

  • 0

I have do this simple app, in this app when I click on start button I want to see the data in Listview, but it does’t work. Can you help me?

mainActivity.java

public class MainActivity extends ListActivity {
public ArrayList<Map<String, String>> list= new ArrayList<Map<String, String>>();
public ListAdapter adapter;
public ProgressDialog progressDialog; 

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

    Button buttonAggiorna = (Button) findViewById(R.id.buttonStart);
    buttonAggiorna.setOnClickListener(new OnClickListener() {
        public void onClick(View arg0) {

        String[] from = { "name", "purpose" };
        int[] to = { android.R.id.text1, android.R.id.text2 };      
 adapter = new SimpleAdapter(MainActivity.this,     list,android.R.layout.simple_list_item_2, from, to);       

  progressDialog = ProgressDialog.show(MainActivity.this, "Getting data", "Loading...");
            taskBack t=new taskBack();
             t.execute();               
        }

    });// fine onClickListner


    Button buttonAllarm = (Button) findViewById(R.id.buttonAllarm);
    buttonAllarm.setOnClickListener(new OnClickListener() {
        public void onClick(View arg0) {            
                AppLog.logString("list size:"+list.size()); 

        }
});


}

 private class taskBack 
 extends    AsyncTask<Void, Void, ArrayList<Map<String, String>>> {

    @Override
    protected ArrayList<Map<String, String>> doInBackground(Void... arg0) {
    ArrayList<Map<String, String>> l = new ArrayList<Map<String, String>>();
    l = startEla();
    return l;
    }

    protected void onPostExecute(ArrayList<Map<String, String>> result) {
        AppLog.logString("Parte onPostExecute");
        list=result;
        setListAdapter(adapter);    
        progressDialog.dismiss();

    }

    private ArrayList<Map<String, String>> startEla() {
    ArrayList<Map<String, String>> list = new ArrayList<Map<String, String>>();
        list.add(putData("android","mobile"));
        list.add(putData("Windows7", "Windows7"));
        list.add(putData("iPhone", "iPhone"));
        return list;

    }

    private Map<String, String> putData(String name, String purpose) {
        HashMap<String, String> item = new HashMap<String, String>();
        item.put("name", name);
        item.put("purpose", purpose);
        return item;

    }
}
}

In this link you can see the xml file enter link description here

Best Regads
A.

  • 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-09T23:34:18+00:00Added an answer on June 9, 2026 at 11:34 pm

    Move these two lines to the main body of the ListActivity…

    String[] from = { "name", "purpose" };
    int[] to = { android.R.id.text1, android.R.id.text2 };      
    

    Remove the following line from the onClick(...) listener in onCreate(...)…

    adapter = new SimpleAdapter(MainActivity.this, list, android.R.layout.simple_list_item_2, from, to);
    

    …and put it in the onPostExecute(...) method of the AsyncTask as follows…

    protected void onPostExecute(ArrayList<Map<String, String>> result) {
        AppLog.logString("Parte onPostExecute");
        list=result;
        adapter = new SimpleAdapter(MainActivity.this, list, android.R.layout.simple_list_item_2, from, to);
        setListAdapter(adapter);    
        progressDialog.dismiss();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple app where you can login it looks like this: {{#view
I have a simple app with a full screen UIWebView. This contains HTML generated
This is a real newbie question. I have simple app that selects a picture
I have a simple GAE app that includes a login/logout link. This app is
I have this simple redirection on my website and it does not rewrite my
I have the following 3 simple pages in a JSF app. index.html start.html confirmSuccess.thml
I have developed a simple app that contains a UITableView that displays data, and
I have a simple rails app where user can send a mass email to
This is probably a simple question... I have a UIView with a button that
I have an android app that starts with a simple screen and a start

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.