public void onClick(View view) {
Intent i = new Intent(First.this,second.class);
startActivity(i);
cat=(EditText) findViewById(R.id.textView_cat);
String s = getIntent().getStringExtra("myString");
cat.setText(s);
Heres는 내 첫 수업 내 두 번째 클래스에서 한 스크린에서 다른 스크린으로 값을 전달
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
@SuppressWarnings("unchecked")
HashMap<String, String> o = (HashMap<String, String>) lv.getItemAtPosition(position);
String selectedFromList = o.get("name");//(String) (lv.getItemAtPosition(position));
Intent i = new Intent(second.this, First.class);
i.putExtra("myString", selectedFromList);
startActivity(i);
}
내가의 버튼을 클릭 한 후 두 번째 클래스 (두 번째 화면)에 가고 싶다 처음 (첫 번째 화면에서). 그런 다음 첫 번째 (화면)에서 두 번째 클래스 (화면)에서 선택한 listitem의 값에 액세스하려고합니다. 하지만 그렇게하는 데 문제가 있습니다. 도와 주시면 감사하겠습니다 .. !!
first.class의 값을 second.class로 전달할 수 있지만 second.class에서 값을 가져 와서 first.class에서 액세스하려고합니다. !! Theres 문제 ... !!!
고맙습니다.
오류 발생을 줄 수 있을까요? 내가 아는 한, 당신은 옳은 일을하는 것처럼 보입니다 : 클릭 된 아이템을 얻고, 당신이 끼어 들었던 데이터를 얻고, putExtra를 시작하고, 활동을 시작하십시오. 아마도 클래스 이름 지정에 문제가 있습니다. logcat의 의미는 무엇입니까? –
정확히 어디 값에 액세스 하시겠습니까? – coder
귀하의 경우 [Activity.startActivityForResult()] (http://developer.android.com/reference/android/app/Activity.html)를 사용하십시오. – yorkw