我需要一个EditText的内容传送到另一个活动上按钮的点击。
这是我目前的code新活动启动:
按钮进入;
@覆盖
保护无效的onCreate(包savedInstanceState){
// TODO自动生成方法存根
super.onCreate(savedInstanceState);
的setContentView(R.layout.intro);
继续=(按钮)findViewById(R.id.bProceed);
proceed.setOnClickListener(新OnClickListener(){
公共无效的onClick(视图v){
意图myIntent =新的意图(Introscreen.this,BillardScoreboardActivity.class);
Introscreen.this.startActivity(myIntent);
myIntent.putExtra ??????
}
});
}
的内容被认为是在未来的活动的整数。
希望有人能帮助我。
最后一个问题:
意图I = getIntent()//错误消息,如果; getintent后不把()
串VAR = i.getStringExtra(笑);
INT转换=的Integer.parseInt(VAR); //错误消息,如果; getIntent后放()
解决方案
EdiText ED =(EditText上)findViewById(R.id.editText);
字符串s = ed.getText.toString();
公共无效的onClick(视图v)
{
意图myIntent =新的意图(Introscreen.this,BillardScoreboardActivity.class);
myIntent.putExtra(you_custom_variable_name,多个);
startActivity(myIntent);
}
Reveiver侧写
意图I = getIntent();
串VAR = i.getStringExtra(you_custom_variable_name);
INT转换=的Integer.parseInt(VAR);
这是简单方法
I need to transfer the contents of an EditText to another activity on Button click.
This is my current code for start of new activity:
Button proceed;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
proceed = (Button) findViewById(R.id.bProceed);
proceed.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(Introscreen.this, BillardScoreboardActivity.class);
Introscreen.this.startActivity(myIntent);
myIntent.putExtra ??????
}
});
}
The contents are supposed to be integers in the next activity.
Hope someone can help me.
Final problem:
Intent i = getIntent() //Error message if ";" isn't put after getintent()
String var = i.getStringExtra("lol");
int convert = Integer.parseInt(var); //Error message if ";" is put after getIntent()
解决方案
EdiText ed = (EditText)findViewById(R.id.editText);
String s = ed.getText.toString();
public void onClick(View v)
{
Intent myIntent = new Intent(Introscreen.this, BillardScoreboardActivity.class);
myIntent.putExtra("you_custom_variable_name",s);
startActivity(myIntent);
}
Reveiver Side Write
Intent i = getIntent();
String var = i.getStringExtra("you_custom_variable_name");
int convert = Integer.parseInt(var);
THis is Simple Method