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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:49:40+00:00 2026-06-03T21:49:40+00:00

I have a MainClass which one is the full app, when I click one

  • 0

I have a MainClass which one is the full app, when I click one button I go to another class (PopupValores) which one I make it looks like a popup. In this class I have a EditText where you type a integer and a button to close this class. My question is how to get that int typed in PopupClass and use it in MainClass. Heres the code for the PopupValores.

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class PopupValores extends Activity implements OnClickListener {

TextView texto;
String mensaje;
EditText editable;
Button ok;
public static int cantidad;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.popupvalores);

    ok = (Button) findViewById (R.id.Bok);
    texto = (TextView) findViewById (R.id.textView1);
    editable = (EditText) findViewById (R.id.editText1);
    mensaje = editable.getText().toString();
    ok.setOnClickListener(this);

    ok.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View arg0) {
            finish();
            return true;
        }
    });


}

public void onClick(View v){
    switch(v.getId()){
    case R.id.Bok:

    String mensaje;
    mensaje = editable.getText().toString();

    cantidad = Integer.parseInt(mensaje);

    texto.setText("New value " + cantidad + ".");

    }
}
}

Then in my MainClass I click a button and it shows the int

int id, vaas = PopupValores.cantidad;
public void onClick (View v)
{   
posicion = (ImageCell) v;
seleccion = posicion.mCellNumber;

if (seleccion == -1){
    ....
    toast (id + " " + vaas);
    ....
}
}

But instead of showing the value declared in PopupValores it shows 0. What I’m doing wrong here?

  • 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-03T21:49:42+00:00Added an answer on June 3, 2026 at 9:49 pm
    1. You need to call the popup Activity with Activity.startActivityForResult()
    2. Once finishing the popup Activity, set the requested result via Activity.setResult() (you can save your data in the intent’s bundle)
    3. In your main Activity, override onActivityResult and retrieve the data
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class API which has full code coverage and uses DI to
I have three classes, one main class, one GUI class which uses awt+swing to
I have an abstract class MainClass which composes Animal class. I derive two classes
i have a Emp class which have one property empName.i am setting this property
I have one main class main, which I use to store the configuration and
I have one class which is calling other classes, this class is my main.
I have a main class(which is basically a netbeans form;drag and drop) from where
Let's assume I have the following code: public class MainClass { public static void
First I want to describe my situation briefly. I have two classes, one MainClass
I have a main class in a program that launches another class that handles

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.