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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:15:57+00:00 2026-05-27T23:15:57+00:00

I am starting to learn android and i have a few questions. I have

  • 0

I am starting to learn android and i have a few questions.
I have my main program as:

public class Radiation_overflowActivity  extends Activity implements OnClickListener {

    EditText init_cores;
        View final_cores;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {


        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

    //Set up click listeners
    init_cores=(EditText) findViewById(R.id.init_cores);
    //init_cores.setOnClickListener(this);
    final_cores=(View) findViewById(R.id.final_cores);
    final_cores.setOnClickListener(this);

     }

    //called when a button is clicked
    public void onClick(View v) {

        switch (v.getId()){

        case R.id.final_cores:
            //int r = Integer.parseInt(init_cores.getText().toString().trim());
            double initcores=Double.parseDouble(init_cores.getText().toString().trim());
            double l=2,t=2;
            double fcores=initcores*Math.exp(-l*t);
            Intent i=new Intent(this,calcs.class);
            i.putExtra("value",fcores);
            startActivity(i);
            break;
         }

       }
      }

Also, my main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/initial_cores" />
<EditText
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/init_cores"
    android:inputType="numberDecimal" />
<Button
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/final_cores"
    android:text="@string/calculate" />
</LinearLayout>

My calcs.java:

public class calcs extends Activity{

    TextView calcs_final;

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.calcs);

        calcs_final=(TextView) findViewById(R.id.calcs_final);

        double f=getIntent().getExtras().getDouble("value");

        calcs_final.setText(Double.toString(f));


}

}

My calcs.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/calcs_final" 
        android:text="@string/result" />


</LinearLayout>

I want to do this:

The user enters data into the edittext (init_cores) and then i want to make some calculations to compute the final_cores and show it to the user.

I have trouble for showing the results.I am starting another activity (calcs.class and calcs.xml).
Where i must do the calculations?To the calcs.class?
Right now,the user enters a number ,presses the “Calculate” button and then it shows the text (from the strings.xml) “Number of cores”” ,but not the result.

Also, can i use the input from the data and from my calculations and make a plot?If you could give me some directions to this.

Finally,is my approach right?

Thank you!

  • 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-27T23:15:58+00:00Added an answer on May 27, 2026 at 11:15 pm

    As per I think your final_cores is a view on which, you want to get your edittext’s value for calculation(Hope I am not wrong)

    So, just do Something like,

    public void OnClick(View v) {
    
        switch (v.getId()){
    
        case R.id.final_cores:
            int r = Integer.parseInt(init_cores.getText().toString().trim());
            Intent i=new Intent(this,calcs.class);
            i.putExtra("value",r);
            startActivity(i);
            break;
        }
    
    }
    

    Remove onClickListener from your init_cores edittext. And get values of r in your Calcs.class using

    int r = getIntent().getExtras().getInt("value");
    

    Also be sure in your edit text always you are entering numeric values so it can be parsable into Integer..

    Try this and let me know what happen..

    Thanks,

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

Sidebar

Related Questions

Starting to learn Canvas and have two classes so far (main one to call
so I am starting to learn how to develop Android Applications. I have experience
I'm just starting to learn Android development. I have included a EditText component in
I'm starting to learn how to develop apps for Android, and I'm having some
I'm starting to learn Haskell and I've heard that many Haskell compilers have especially
I am just starting to learn how to use RMI, and I have a
I'm just starting to learn AspectJ, and I have use-case for say, User login.
I'm starting to learn the android NDK and I've instantly come up against a
I am starting to learn Ruby on Rails but have been stuck at the
I'm a flex programmer who has just started to learn android today, successfully starting

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.