我的情况是特殊的一点点,所以我会在这里解释。 我有2个活动,先用2编辑和1键和第二只用一个按钮。 当pressing在活动1中的程序按钮发送意图的信息从文本编辑到活动2和活动2显示。 在活动2的按钮仅要回活动1,我这样称呼它
My case is a little bit of special so I will explain here. I have 2 activities, first with 2 edits and 1 button and second with just a button. When pressing the button in activity 1 the program sends with intent the informations from text edits to activity 2 and displays it on activity 2. On activity 2 the button is only to get back to activity 1 and i call it like this
Button next = (Button) findViewById(R.id.button2);
Intent myIntent = getIntent();
String nume = myIntent.getStringExtra("nume");
String prenume = myIntent.getStringExtra("prenume");
next.setText(nume + " " + prenume);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent();
setResult(RESULT_OK, intent);
finish();
}
});
我第一次在编辑输入的相关信息,他们都显示正常的活动2,但在我回来的活性并进入新的价值观上的活动2编辑显示的值进入第一次。
The first time i enter infos in edits they are displayed ok in activity 2, but after I come back to activity 1 and enter new values on edits on the activity 2 are displayed the values entered first time.
所以,问题似乎是由意图通过编辑不会被我preSS按钮1传递到活动2开始的第二atempt每一次更新。
So the problem seems to be that the edits passed by intent wont be updated each time I press the button 1 to pass to Activity 2 starting with the second atempt.
推荐答案
导航从第一个到第二个:
Navigate from First to Second:
Button next = (Button) findViewById(R.id.button2);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),Second.class);
intent.putExtra("Tag", "Value");
startActivity(intent);
finish();
}
});
二,以第一:
Second to First:
Button previous= (Button) findViewById(R.id.button);
previous.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent intent = new Intent(getApplicationContext(),First.class);
startActivity(intent);
}
});
在创建第二个活动:
Intent i = getIntent();
String val = i.getStringExtra("Tag");
相关推荐
最新文章