마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

intent 관련 질문드립니다.

0 추천

xml읽어서 intent로 Axtivity 연결하는 소스를 짰습니다.

if (position == 0) {
       Intent intent0 = new Intent(Bus8101.this, Jungtime.class);
    intent0.putExtra("name", 90000201);
    intent0.putExtra("a", 54838);
    intent0.putExtra("b", 1);
       startActivity(intent0);
  }
  else if (position == 1) {
   Intent intent1 = new Intent(Bus8101.this, Jungtime.class);
   intent1.putExtra("name", 90000201);
   intent1.putExtra("a", 57536);
   intent1.putExtra("b", 2);
   startActivity(intent1);
  }
  else if (position == 2) {
   Intent intent2 = new Intent(Bus8101.this, Jungtime.class);
   intent2.putExtra("name", 90000201);
   intent2.putExtra("a", 54988);
   intent2.putExtra("b", 3);
   startActivity(intent2);
  }

 

이렇게 넘겨서

 

      try{
             URL url = new URL("http://ws.bus.go.kr/api/rest/arrive/getArrInfoByRoute?" +
               "ServiceKey===" +
               "&stId=" +a+ "&busRouteId="+name + "&ord=" +b);

 

이렇게 받도록 짰는데

이렇게 하다보니까

 

    intent0.putExtra("name", 90000201);
    intent0.putExtra("a", 54838);
    intent0.putExtra("b", 1);

여기부분을 계속해서 막노동으로 작성해야하는 수고가있어서

 

 

xml 보시면

 

이런식으로 항목이 쭉 뜨는데

직접 54838을 입력하는게 아니라 stId자체를 받아와서 입력시키고싶은데 

어떤식으로 짜야할까요..

익명사용자 님이 2013년 9월 30일 질문

1개의 답변

0 추천
xml에 있는 정보를 class로 묶어서 arraylist를 이용하시면 됩니다.
아나콘다v (4,670 포인트) 님이 2013년 10월 1일 답변
...