如何在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();
}
}
答案 0 :(得分:0)
Intent intent = new
Intent(getApplicationContext(),SecondActivity.class);
intent.putExtra("myKey",AnyValue);
startActivity(intent);
现在您可以通过...获取传递的值
Bundle extras = intent.getExtras();
String tmp = extras.getString("myKey");