0

How to pass string in bundle in onClick method (how to pass page contentpage string in onclick bundle)

 Button button[] = new Button[z];
 String pagetitle;
 String pagecontent;

                for (int k = 0; k < z; k++) {
                    button[k] = new Button(this);
                    addbutton.addView(button[k]);
                    pagetitle=null;
                    pagecontent=null;

                    for (int j = 0; j <= k; j++) 
                    {
                        pagetitle=stringArrayTitle.get(j);
                        pagecontent=stringArrayContent.get(j);

                        //System.out.println("titile array list"+ y);
                        button[k].setText(pagetitle);
                        button[k].setOnClickListener(new OnClickListener() {

                            public void onClick(View v) {
                                // TODO Auto-generated method stub
                                Bundle ba= new Bundle();                                    
                            }
                        });
                    }                       
                }
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
Akshay
  • 2,506
  • 4
  • 34
  • 55
Prashant09
  • 347
  • 3
  • 17

1 Answers1

0
Intent intent = new
Intent(getApplicationContext(),SecondActivity.class);
intent.putExtra("myKey",AnyValue);  
startActivity(intent);

Now you can get the passed values by...

Bundle extras = intent.getExtras(); 
String tmp = extras.getString("myKey");
ckpatel
  • 1,926
  • 4
  • 18
  • 34
  • http://stackoverflow.com/questions/768969/passing-a-bundle-on-startactivity please read it i thing its helpfull for u – ckpatel Aug 20 '12 at 06:54