0

How to pass string in bundle in onClickmethod (how to pass page contentpage string in onclickbundle)

 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();
            }
        }
4

1 回答 1

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

现在您可以通过...获取传递的值

Bundle extras = intent.getExtras(); 
String tmp = extras.getString("myKey");
于 2012-08-20T06:35:23.687 回答