Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In the calling activity </p> <pre><code>Intent i = new Intent(A.this, B.class); i.putExtra("string", editText.getText()); startActivity(i); </code></pre> <p>In the called activity, have a String to get this extra and pass it again to when onStop()</p> <pre><code>Bundle extras = getIntent().getExtras(); String str = extras.getString("string"); </code></pre> <p>In home activity :</p> <pre><code>public void onCreate(Bundle savedInstanceState){ .... if(getIntent().getExtras()!=null) { Bundle extras = getIntent().getExtras(); if(extras.getInt("TableNo") != null &amp;&amp; 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&lt;GlobalClass.myval.length;i++){ //System .out.println("Clicked--&gt;"+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); } }); </code></pre> <p>SECOND ACTIVITY:</p> <pre><code> 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&lt;String&gt; st=GlobalClass.myval; //ArrayAdapter&lt;String&gt; ada = new ArrayAdapter&lt;String&gt;( this, android.R.layout.simple_list_item_1,st); l1.setAdapter(new EfficientAdapter(TicketActivity.this)); l1.setOnItemClickListener(new OnItemClickListener(){ public void onItemClick(AdapterView&lt;?&gt; 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); } }); } } </code></pre> <p><strong>Also, try to name your variables logically. Naming randomly is not a good programing practice and may hamper code maintainability.</strong></p> <p>Note: Please rectify some small errors(if any). I dont have android sdk right now so can not compile this code.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload