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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:24:41+00:00 2026-06-10T19:24:41+00:00

I am using two editText boxes like table no and no of guest. if

  • 0

I am using two editText boxes like “table no” and “no of guest”. if I fill the editText box and select some items in the listView then go to the next activity and come back to previous activity again where the EditText box is available the value is empty. My requirement is that when I come back to the previous activity the EditText displays the data I’ve entered before.

SENDING EDITTEXT DATA:

   b1.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

                    //for (int i=0;i<GlobalClass.myval.length;i++){

                   //System .out.println("Clicked-->"+GlobalClass.myval[i]);

                    //}

            String tno = e1.getText().toString();
            int tn = Integer.parseInt(tno);

            Intent i=new Intent(getApplicationContext(),TicketActivity.class);
            Bundle b=new Bundle();
            b.putInt("Table No:", tn);
            i.putExtras(b);
            String et= e2.getText().toString();
            int et1 = Integer.parseInt(et);
            Bundle be=new Bundle();
            be.putInt("Guest:", et1);
            i.putExtras(be); 

            startActivity(i);



        }
    });

SECOND ACTIVITY:

   public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.ticket);


t1=(TextView)findViewById(R.id.textView3);
t2=(TextView)findViewById(R.id.textView5);
l1=(ListView)findViewById(R.id.listView1);
or=(ImageButton)findViewById(R.id.imageButton7);
ho=(ImageButton)findViewById(R.id.imageButton4);
de=(ImageButton)findViewById(R.id.imageButton1);
pl=(ImageButton)findViewById(R.id.imageButton2);
mi=(ImageButton)findViewById(R.id.imageButton3);
pa=(ImageButton)findViewById(R.id.imageButton5);
pr=(ImageButton)findViewById(R.id.imageButton6);
// l1.setItemsCanFocus(false);
//l1.setFocusable(true);
//l1.setClickable(true);

//Get the Table no Value From Edit Text


Intent i1=getIntent();
Bundle b=i1.getExtras();
int num=b.getInt("Table No:");
pno=Integer.toString(num);
t1.setText(pno);

//Get The Guest Value From Edit Text
 Intent i2=getIntent();
 Bundle b1=i2.getExtras();
 int num1=b1.getInt("Guest:");
 pno1=Integer.toString(num1);
 t2.setText(pno1);




// List<String> st=GlobalClass.myval;

   //ArrayAdapter<String> ada = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1,st);

    l1.setAdapter(new EfficientAdapter(TicketActivity.this));

     l1.setOnItemClickListener(new OnItemClickListener(){
 public void onItemClick(AdapterView<?> parent,View view,int position,long id){

 st2=HomeActivity.select1[position];

    Toast.makeText(getApplicationContext(), "Selected:" + st2, Toast.LENGTH_SHORT).show();

    }
    });

 //GO TO PREV ACTIVITY:


    ho.setOnClickListener(new View.OnClickListener() {

    public void onClick(View v) {
        Intent o2=new Intent(TicketActivity.this,HomeActivity.class);

        startActivity(o2);

    }
  });

      }

    }
  • 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-10T19:24:43+00:00Added an answer on June 10, 2026 at 7:24 pm

    In the calling activity

    Intent i = new Intent(A.this, B.class);
    i.putExtra("string", editText.getText());
    startActivity(i);
    

    In the called activity, have a String to get this extra and pass it again to when onStop()

    Bundle extras = getIntent().getExtras();
    String str = extras.getString("string");
    

    In home activity :

    public void onCreate(Bundle savedInstanceState){
    ....
      if(getIntent().getExtras()!=null) {
         Bundle extras = getIntent().getExtras();
         if(extras.getInt("TableNo") != null && extras.getInt("Guest") != null) }
            e1.setText(extras.getInt("TableNo").toString());
            e2.setText(extras.getInt("Guest").toString());
         }
      }
    ....
    }
    
    
       b1.setOnClickListener(new View.OnClickListener() {
    
        public void onClick(View v) {
    
                    //for (int i=0;i<GlobalClass.myval.length;i++){
    
                   //System .out.println("Clicked-->"+GlobalClass.myval[i]);
    
                    //}
    
            String tno = e1.getText().toString();
            int tn = Integer.parseInt(tno);
            String et= e2.getText().toString();
            int et1 = Integer.parseInt(et);
    
            Intent i=new Intent(getApplicationContext(),TicketActivity.class);
            i.putExtras("TableNo", tn);
            i.putExtras("Guest", et1); 
    
            startActivity(i);
    
    
    
        }
    });
    

    SECOND ACTIVITY:

       public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ticket);
    
    
    t1=(TextView)findViewById(R.id.textView3);
    t2=(TextView)findViewById(R.id.textView5);
    l1=(ListView)findViewById(R.id.listView1);
    or=(ImageButton)findViewById(R.id.imageButton7);
    ho=(ImageButton)findViewById(R.id.imageButton4);
    de=(ImageButton)findViewById(R.id.imageButton1);
    pl=(ImageButton)findViewById(R.id.imageButton2);
    mi=(ImageButton)findViewById(R.id.imageButton3);
    pa=(ImageButton)findViewById(R.id.imageButton5);
    pr=(ImageButton)findViewById(R.id.imageButton6);
    // l1.setItemsCanFocus(false);
    //l1.setFocusable(true);
    //l1.setClickable(true);
    
    //Get the Table no Value From Edit Text
    
    
    Intent i1=getIntent();
    Bundle b=i1.getExtras();
    int num=b.getInt("TableNo"); 
    pno=Integer.toString(num);
    t1.setText(pno);
    
    //Get The Guest Value From Edit Text
     Intent i2=getIntent();
     Bundle b1=i2.getExtras();
     int num1=b1.getInt("Guest");
     pno1=Integer.toString(num1);
     t2.setText(pno1);
    
    
    
    
    // List<String> st=GlobalClass.myval;
    
       //ArrayAdapter<String> ada = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1,st);
    
        l1.setAdapter(new EfficientAdapter(TicketActivity.this));
    
         l1.setOnItemClickListener(new OnItemClickListener(){
     public void onItemClick(AdapterView<?> parent,View view,int position,long id){
    
     st2=HomeActivity.select1[position];
    
        Toast.makeText(getApplicationContext(), "Selected:" + st2, Toast.LENGTH_SHORT).show();
    
        }
        });
    
     //GO TO PREV ACTIVITY:
    
    
        ho.setOnClickListener(new View.OnClickListener() {
    
        public void onClick(View v) {
    
            String tno = t1.getText().toString();
            int tn = Integer.parseInt(tno);
            String et= t2.getText().toString();
            int et1 = Integer.parseInt(et);
    
            Intent o2=new Intent(TicketActivity.this,HomeActivity.class);
            i.putExtras("TableNo", tn);
            i.putExtras("Guest", et1);
            startActivity(o2);
    
        }
      });
    
          }
    
        }
    

    Also, try to name your variables logically. Naming randomly is not a good programing practice and may hamper code maintainability.

    Note: Please rectify some small errors(if any). I dont have android sdk right now so can not compile this code.

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

Sidebar

Related Questions

I Using Two Table User And Location In User Table I having LocationId And
I have some problems using two dimensional array. static const int PATTERNS[20][4]; static void
Using VB 6 Using two DTPicker in my project, I want to select monthly
I have created two EditText fields and a single submit button in Android using
I have created two input fields using EditText, a TimePicker , a Spinner along
I have two EditText boxes editText1 and editText2 and I'm trying to give input
I am using two textWatcher objects, which are assigned to two edittext . In
In an Android app, I'm using two EditText controls and multiplying their two values.
I am using AlertDialog.Builder to create a dialog with a EditText and two buttons,
Using two tables in MSSQL: One table, [CUSTOMER], containing information on donors. - Relevent

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.