在我的应用程序中,当用户单击微调器中的项目时,它将转到新活动,因为我有 5 个编辑文本,因为我保留微调器的值,当用户编辑此值并按下保存按钮时,编辑的值应替换微调器中的旧值。我怎样才能做到这一点?请帮助我..
我的微调器代码:
public class BudgetJulyo4Activity extends Activity
{
/** Called when the activity is first created. */
DBadapter db =new DBadapter(this);
DBadapterRec dbrec=new DBadapterRec(this);
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b1=(Button)findViewById(R.id.button1);
Button b2=(Button)findViewById(R.id.button2);
Button b3=(Button)findViewById(R.id.button3);
Button b4=(Button)findViewById(R.id.button4);
Spinner s1=(Spinner)findViewById(R.id.spinner);
Spinner s2=(Spinner)findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
this, R.array.recurr_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s1.setAdapter(adapter);
String group[]=getResources().getStringArray(R.array.group_array);------>Before calling edit(i.e when enters first time i am showing some hardcore value)
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item,group);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(adapter1);
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) ------>After edit option.
{
java.lang.System.out.println("Inside act");
// TODO Auto-generated method stub
// }
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==1)
{
Spinner s2=(Spinner)findViewById(R.id.spinner1);
String str1=data.getStringExtra("grp1val");
String str2=data.getStringExtra("grp2val");
String str3=data.getStringExtra("grp3val");
String str4=data.getStringExtra("grp4val");
String str5=data.getStringExtra("grp5val");
String str6="Edit";
String group[] = new String[] { str1,str2,str3,str4,str5,str6};
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(
this, android.R.layout.simple_spinner_item,group);
adapter1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s2.setAdapter(adapter1);
}
}
}