私は3つのアクティビティを持っています。 Activity
では、CSV
ファイルからデータを読み込み、ListView
を使用して、EditText
に表示しています。今、EditText
の値を別のActivity
に渡したいと思います。この問題を解決するために何ができるのですか?リストビューからEditText値を別のアクティビティに渡す
コード:
String dir = Environment.getExternalStorageDirectory() + "/grocery/data/" + spinner.toString();
final File csvfile = new File(dir.toString());
ListView listView = (ListView) findViewById(R.id.listview);
MyList adapter = new MyList(getApplicationContext(), R.layout.activity_editfeild);
listView.setAdapter(adapter);
studentid= (EditText) findViewById(R.id.et_studentid);
Schoolname= (EditText) findViewById(R.id.et_schoolname);
schoolAdress= (EditText) findViewById(R.id.et_schooladd);
studentname=(EditText) findViewById(R.id.et_studentname);
fathername= (EditText) findViewById(R.id.et_fathername);
mothername= (EditText) findViewById(R.id.et_mothername);
studentaddress= (EditText) findViewById(R.id.et_studentadd);
//Toast.makeText(Editinfo.this, studentid.getText().toString(), Toast.LENGTH_SHORT).show();
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(csvfile);
} catch (FileNotFoundException e){
e.printStackTrace();
}
CSVReader reader = new CSVReader(inputStream);
final List<String[]> myList=reader.read();
for (String[] data : myList) {
adapter.add(data);
}
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Editinfo1.class);
intent.putExtra("spinner", chosenOption);
intent.putExtra("studentid", studentid.getText().toString());
intent.putExtra("schoolname", Schoolname.getText().toString());
intent.putExtra("schooladdress", schoolAdress.getText().toString());
intent.putExtra("studentname", studentname.getText().toString());
intent.putExtra("fathername", fathername.getText().toString());
intent.putExtra("mothername", mothername.getText().toString());
intent.putExtra("studentaddress", studentaddress.getText().toString());
intent.putExtra("myList", (Serializable) myList);
//intent.putExtra("mylist", myList);
startActivity(intent);
}
});
}
を逃したがあれば私に知らせてください。 – Shailesh
ありがとう...あなたがアイテムの位置を渡す方法についての簡単なアイデアを与えることができます –
これを確認してくださいhttp://stackoverflow.com/questions/5374546/passing-arraylist-through-intent – Shailesh