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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:15:51+00:00 2026-05-21T18:15:51+00:00

I am trying to put a list under 2 editTexts and 2 buttons. I

  • 0

I am trying to put a list under 2 editTexts and 2 buttons. I am wondering how I can have the list be populated with strings after a button press.

Right now, I have an ArrayList and when the button is hit, it calls a method that uses data from the editTexts and adds values to the ArrayList. When I run it, it force closes. All I want to do is update the list with new values. Any idea are greatly appreciated.

Here is my code simplified a lot. This is where I am.

    public class test extends ListActivity{

    EditText currentText;   
    int current;
    EditText goalText;
    int goal;
            int[] xpTable = {1,200,30000,400000,500000};

    static ArrayList<String> objs = new ArrayList<String>();


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


        Button calc = (Button) findViewById(R.id.calc);
        calc.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                myMethod();
            }

        });

    }

    public void myMethod(){

        currentText = (EditText)this.findViewById(R.id.xp);
        goalText = (EditText)this.findViewById(R.id.level);
        current = Integer.parseInt(currentText.getText().toString());
        goal = Integer.parseInt(goalText.getText().toString());
        int needed = xpTable[goal] - current;

        double laps = 0;
        double value1= 50.5;
        double value2= 100;



        laps = (needed/value1);
        if (laps % 1 != 0)
            laps = (laps - laps % 1) + 1;
        objs.add((int)laps + " value1");

        laps = (needed/value2);
        if (laps % 1 != 0)
            laps = (laps - laps % 1) + 1;
        objs.add((int)laps + " value2");


        setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, objs));
    }
}

Sorry for all my simple questions, This community is great for help.

  • 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-05-21T18:15:52+00:00Added an answer on May 21, 2026 at 6:15 pm

    just re-set the adapter using your new value :

    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, your_new_value));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're trying to put together kiosk solution where we can charge people by hour
I have a linq query and I am trying to put that in to
I'm trying to list all files and folders recursively under a given folder in
I am trying to create a suggestion list under a text input field. Currently
ASP.NET3.5 Webforms. Am trying to put a validator on the drop down list, only
I'm trying my hand in asp.net. I have a dropdown list in my page.There's
Im trying to put an html embed code for a flash video into the
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it
I am trying to put some distributed caching into play, I'm using this indeXus.Net
I'm trying to put a Message back into an MSMQ when an exception is

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.