2014-12-05 1 views
-1

안녕하세요 저는 Android 프로젝트에서 일하고 있습니다. 남성용 및 여성용 스포츠로 확장 가능한 목록보기를 만들었습니다. 각각의 밑에 나는 스포츠의 명부가있다. 당신이 그것을 클릭 한 후에 각 스포츠는 새로운 활동을 엽니 다. 예 : 남자 스포츠를 클릭 한 다음 야구를 클릭하면 데이터베이스에서 모든 야구 이벤트를 나열한 새로운 활동이 열립니다. 이제 각 스포츠에 대한 확장 가능한 목록보기 및 활동을 작성한 시점에서 각 스포츠를 데이터베이스에서 채워야합니다.스포츠 활동에 데이터를 채우는 방법은 무엇입니까?

this Main (id=831962574768) 
groupedFeeds ArrayList (id=831963150464)  
    array Object[12] (id=831963153088) 
     [0] GroupedFeed (id=831963152968) 
      category "Women's Golf" (id=831962986192)  
      feeds ArrayList (id=831963152992)  
     [1] GroupedFeed (id=831963153592) 
      category "Volleyball" (id=831962991720) 
      feeds ArrayList (id=831963153616)  
     [2] GroupedFeed (id=831963153744) 
      category "Men's Soccer" (id=831962996544)  
      feeds ArrayList (id=831963153768)  
     [3] GroupedFeed (id=831963153896) 
      category "Women's Soccer" (id=831963006320) 
      feeds ArrayList (id=831963153920)  
     [4] GroupedFeed (id=831963154864) 
      category "Men's Golf" (id=831963016488) 
      feeds ArrayList (id=831963154888)  
     [5] GroupedFeed (id=831963155072) 
      category "Men's Cross Country" (id=831963036816) 
      feeds ArrayList (id=831963155096)  
     [6] GroupedFeed (id=831963155224) 
      category "Women's Cross Country" (id=831963041984) 
      feeds ArrayList (id=831963155248)  
     [7] GroupedFeed (id=831963155472) 
      category "Men's Bowling" (id=831963093056) 
      feeds ArrayList (id=831963155496)  
     [8] GroupedFeed (id=831963155712) 
      category "Women's Bowling" (id=831963098224) 
      feeds ArrayList (id=831963155736)  
     [9] GroupedFeed (id=831963155864) 
      category "Women's Basketball" (id=831963170720) 
      feeds ArrayList (id=831963155888)  
     [10] GroupedFeed (id=831963157504) 
      category "Men's Basketball" (id=831963299944)  
      feeds ArrayList (id=831963157528)  
     [11] null  
    modCount 11 
    size 11 
loader RSSLoader (id=831962575480)  
aMan AssetManager (id=831962469744) 

가 지금은 각 스포츠 (활동)에 대한 내 확장 목록보기를 채울 필요가 : 내 데이터베이스는 여기 배열 목록 정렬 내 데이터베이스를 보는 방법 0 (11)에서 배열 목록에 정렬됩니다. 여기 내 스포츠를 채울 함수를 만들어야하는 Main 메서드가 있습니다. 나는 그 함수가있을 것으로 생각되는 의견과 그것이 ecah 스포츠 내부에 채워져 있어야한다고 생각하는 의견을 달았다. 제발 누군가가 내가 갇혀 있고 도울 수 없다면 제발.

public class MainActivity<View> extends ActionBarActivity { 

     ExpandableListView exv; 
     List<GroupedFeed> gfList; 
     GroupedFeed gfResult; 

     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_main); 
      exv=(ExpandableListView)findViewById(R.id.expandableListView1); 
      exv.setAdapter(new MyAdapter(this)); 
      exv.setOnChildClickListener(new OnChildClickListener() { 

       **// Create GroupedFeed findFeed(String locateSport); 

       public boolean onChildClick(ExpandableListView parent, 
         android.view.View v, int groupPosition, int childPosition, 
         long id) { 
        switch (groupPosition) 
        { 
        case 0: 
          switch (childPosition) 
          { 
          case 0: 

           **// Call gfResult = findFeed("Men's Baseball"); 
           Baseball(); **// pass gfResult 
           break; 
          case 1: 
           MensBasketball(); 
           break; 
          case 2: 
           MensBowling(); 
           break; 
          case 3: 
           MensCross_Country(); 
           break; 
          case 4: 
           MensGolf(); 
           break; 
          case 5: 
           MensSoccer(); 
           break; 
          case 6: 
           MensTrack_Field(); 
           break; 
          } 
         break; 
         case 1: 
          switch (childPosition) 
          { 
          case 0: 
           WomensBasketball(); 
           break; 
          case 1: 
           WomensBowling(); 
           break; 
          case 2: 
           WomensCross_Country(); 
           break; 
          case 3: 
           WomensGolf(); 
           break; 
          case 4: 
           WomensSoccer(); 
           break; 
          case 5: 
           Softball(); 
           break; 
          case 6: 
           WomensTrack_Field(); 
           break; 
          case 7: 
           Volleyball(); 
           break; 
          } 

        } 
        return false; 
       } 

       private void Baseball() { 
        Intent myIntent = new Intent(MainActivity.this, Baseball.class); 
        startActivity(myIntent); 
       } 

       private void MensBasketball() { 
        Intent myIntent = new Intent(MainActivity.this, MensBasketball.class); 
        startActivity(myIntent); 
       } 

       private void WomensBasketball() { 
        Intent myIntent = new Intent(MainActivity.this, WomensBasketball.class); 
        startActivity(myIntent); 
       } 

       private void MensBowling() { 
        Intent myIntent = new Intent(MainActivity.this, MensBowling.class); 
        startActivity(myIntent); 
       } 

       private void WomensBowling() { 
        Intent myIntent = new Intent(MainActivity.this, WomensBowling.class); 
        startActivity(myIntent); 
       } 

       private void MensCross_Country() { 
        Intent myIntent = new Intent(MainActivity.this, MensCross_Country.class); 
        startActivity(myIntent); 
       } 

       private void WomensCross_Country() { 
        Intent myIntent = new Intent(MainActivity.this, WomensCross_Country.class); 
        startActivity(myIntent); 
       } 

       private void MensGolf() { 
        Intent myIntent = new Intent(MainActivity.this, MensGolf.class); 
        startActivity(myIntent); 
       } 

       private void WomensGolf() { 
        Intent myIntent = new Intent(MainActivity.this, WomensGolf.class); 
        startActivity(myIntent); 
       } 

       private void MensSoccer() { 
        Intent myIntent = new Intent(MainActivity.this, MensSoccer.class); 
        startActivity(myIntent); 
       } 

       private void WomensSoccer() { 
        Intent myIntent = new Intent(MainActivity.this, WomensSoccer.class); 
        startActivity(myIntent); 
       } 

       private void Softball() { 
        Intent myIntent = new Intent(MainActivity.this, Softball.class); 
        startActivity(myIntent); 
       } 

       private void MensTrack_Field() { 
        Intent myIntent = new Intent(MainActivity.this, MensTrack_Field.class); 
        startActivity(myIntent); 
       } 

       private void WomensTrack_Field() { 
        Intent myIntent = new Intent(MainActivity.this, WomensTrack_Field.class); 
        startActivity(myIntent); 
       } 

       private void Volleyball() { 
        Intent myIntent = new Intent(MainActivity.this, Volleyball.class); 
        startActivity(myIntent); 
       } 

      }); 
      Main myMain = new Main(); 
      try { 
      // AssetManager aMan = getAssets(); 
    //   @SuppressWarnings("unused") 
       this.gfList = myMain.loadRSS(); 
      } catch (Exception e) { 
       System.out.println("Hosed"); 
      } 
     } 
    } 
+0

을 대신에 전화를 클릭 아이에에 함수를 호출 야구 또는 기타 활동. –

+0

코드를 제공 할 수 있습니까? –

+0

클릭 할 때 자녀 내부의 전환 사례 대신 각 활동 세부 정보에서 댓글이 달린 코드를 호출하면되는 코드는 필요 없습니다. –

답변

0

당신이 활동을 시작하는 데 사용하는 목적의 활동에 데이터를 전달하는 것이 가장 쉬운 방법 :

Intent intent = new Intent(getBaseContext(), YourActivity.class); 
intent.putExtra("youe_data_key", yourData); 
startActivity(intent); 
+0

입력해야하는 코드를 제공해 주시겠습니까? 나는 안드로이드에 새로운 사람이야. –

+0

이것이 맞습니까? 개인 무효 Baseball() { \t 의도 myIntent = 새로운 의도 (getBaseContext(), Baseball.class); \t Intent.putExtra ("남자 야구", groupedFeed); \t startActivity (myIntent); –

+0

네, 맞습니다. 이것으로 계속 진행할 수 있습니다 –

관련 문제