2011-07-04 4 views
1

코드를 넣으려면 다시 onResume() 메서드를 넣고 탭 클릭으로 다시로드 할 때마다이 메서드를 실행해야하지만 문제는 이제 데이터가 처음으로로드됩니다. 탭에서 처음 클릭 할 때 목록보기로 서버에서 탭을 변경하고 다시로드 할 때 강제로 닫고 강제로 "배열 인덱스가 바운드 예외"가됩니다. 그것은 이전에로드 된 데이터를 제거하지 않기 때문에 제거하거나 탭 클릭에 새 데이터를 다시로드하는 방법 그래서 예외가 발생하지 않는 것 같아요? 이전 데이터를 삭제하는 방법은 onResume()을 통해 새 데이터를로드하기 전에 의미합니까?보기에서 "ontabchange()"탭을 변경할 때 onresume() 메서드를 실행하십시오.

보호 된 void onPause() { super.onPause();

} 


protected void onResume() 
{ 

    super.onResume(); 

    **new ProgressTask6().execute();** 

} 

private class ProgressTask6 extends AsyncTask<String, Void, Boolean> { 
private ProgressDialog dialog; 
      private Context context; 
      @Override 
      protected void onPreExecute() { 
       dialog = new ProgressDialog(OpeningToday.this); 
       dialog.setMessage("Processing..."); 
       dialog.setIndeterminate(true); 
       dialog.setCancelable(false); 
       dialog.show(); 
     } 

      @Override 
     protected void onPostExecute(final Boolean success) { 

       if (dialog.isShowing()) 
       { 
       dialog.dismiss(); 
       setListAdapter(new MyAdapter(OpeningToday.this)); 
      } 


    } 
     @Override 
     protected Boolean doInBackground(String... args) { 
       try{ 


     } catch (Exception e){ 
      Log.e("tag", "error", e); 
      return false; 
     } 
     return null; 
     } 
     class MyAdapter extends BaseAdapter implements OnClickListener 
     { 


        }   

        @Override 
        public int getCount() { 
         }      } 

        /* Not implemented but not really needed */ 
        @Override 
        public Object getItem(int position) { 
         return null; 
        } 

        /* Not implemented but not really needed */ 
        @Override 
        public long getItemId(int position) { 
         return 0; 
        } 

        @Override 
        public View getView(int position, View ConvertView, ViewGroup parent) 
        { 
         View v = inflater.inflate(R.layout.listitem_layout, parent, false); 
         // Log.i("array galoijewdh..",keywordresulttab.array_galleryname[position]); 
         Log.i("saurabh trivedi","saurabh trivedui"); 
         // Variables.a=3; 
         String gallerynames = keywordresulttab.array_galleryname[position]; 
         String addresses = keywordresulttab.array_address[position];    
         TextView tv = (TextView) v.findViewById(R.id.barrio); 
         tv.setText(gallerynames); 
         tv = (TextView) v.findViewById(R.id.ciudad); 
         tv.setText(addresses); 
         ((BaseAdapter)(getListAdapter())).notifyDataSetChanged(); 
         return v; 
        } 
       @Override 
        public void onClick(DialogInterface dialog, int which) { 
         // TODO Auto-generated method stub 

        } 

        } 

}

+0

사이트 목록이란 무엇입니까? 파싱 ​​된 데이터를 저장하는 목록입니까? –

+0

클래스 내 getter 및 setter metho 있고 가변 데이터를 저장하기위한 배열 목록을 사용합니다 .. 더 아래에 내 qus 일부로 이동합니다 또한 사이트 목록 클래스를 추가했습니다 – SRam

답변

0

onResume()의 반대 인 onPause()에서 데이터를 삭제/인덱스를 초기화합니다.

  • onCreate() - - onDestroy()
  • onStart()/onRestart() - onStop()
  • onResume()-onPause()
당신이 반대 방법에 필요한 청소 - ( activity lifecycle에 따라) 엄지 손가락의 규칙으로

+0

안녕하세요 MByD 나는 새로운 안드로이드 및 Java u 설명 할 수 있습니다. 나에 대한 자세한 내용은 pls plsmeans 응답을 위해 이전에로드 된 데이터를 무료로하는 방법 – SRam

+0

onPause()에서 인덱스 초기화/데이터 삭제 방법? – SRam

+0

정확히 당신이 거기에서 뭘하고 있는지 모르겠으니 말하기 어렵습니다. IMO가 어디에 있어야하는지 말씀 드렸지만 더 자세히 알려면 코드를보아야합니다. – MByD

관련 문제