如何在onclick方法中传递bundle中的字符串(如何在onclick bundle中传递页面contentpage字符串)

时间:2012-08-20 06:29:14

标签: android

如何在onClick方法中传递字符串中的字符串(如何在onclick包中传递页面内容页面字符串)

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

1 个答案:

答案 0 :(得分:0)

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

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

Bundle extras = intent.getExtras(); 
String tmp = extras.getString("myKey");