2013-11-24 5 views
0

심각도, 심각도는 ProgressBar로 표시됩니다. NAME님께 서 해당 코드가 정확하지 않습니다 : mProgress.setProgress(0); ProgressBar가 없습니다. onCreate()에서 PreogressBar를 초기화했습니다. 당신의 도움이Android ProgressBar NPE

ListAdapter adapter = new ArrayAdapter<Dettaglio>(this, R.layout.dettaglio, R.id.tv_totale_group, dettagli){ 

        @Override 
        public View getView(int position, View convertView, ViewGroup parent) { 
          View row = super.getView(position, convertView, parent); 

          TextView tvEn, tvCaa, tvPer; 
          tvEn = (TextView) row.findViewById(R.id.tv_to_group); 
          tvCaa = (TextView) row.findViewById(R.id.tv_cat_group); 
          tvPer = (TextView) row.findViewById(R.id.tv_perc_cat);  
          ProgressBar mProgress; 
       mProgress = (ProgressBar) findViewById(R.id.progress_e); 
          mProgress.setProgress(0); 
          mProgress.setMax(100); 



          Dettaglio d = dettagli.get(position); 

          tvCaa.setText(d.categorie+""); 

          double value = Double.valueOf(d.en); 
          NumberFormat formatter = NumberFormat.getCurrencyInstance(); 
          String en = formatter.format(value); 
          tvEn.setText(en+""); 

          //percent------------------------- 
          double totaleE = 0; 
          for (Dettaglio c : dettagli){ 
            totaleE += c.en; 
          } 

          value = d.en/totaleE *100;          

          DecimalFormat decimalFormat = new DecimalFormat("0.#"); 
          String en1 = decimalFormat.format(value); 
          tvPer.setText(en1+"%"); 

          //----PROGRESS BAR---------------------------------------- 

          int valore_per_barra = (int) Math.floor(value); 

          mProgress.setProgress(valore_per_barra); 


          return row; 
        } 
      }; 

      lista.setAdapter(adapter); 
+1

어디'초기화 mProgress'되어 주셔서 감사합니다? 메소드의 – Raghunandan

+0

onCreate() mProgress = (ProgressBar) findViewById (R.id.progress_e); – user2996988

답변

0

listAdapter 내부의 ProgressBar를 초기화하는 대신 당신이 한 OnCreate

+0

이렇게하면 이클립스는 빨간색으로 강조된다. – user2996988

+0

public class MainActivity extends Activity { private int mProgress = 0; ---- 신중하게! – iGio90

+0

@ iGio90 진행률 표시 줄. 당신은 틀리다 – Raghunandan