title: Showing ArrayList in ListView using BaseAdapter
body: <p>I am having a hard time displaying the data in my <code>ArrayList</code>  in <code>ListView</code> . I'm using <code>BaseAdapter</code> for showing the data. I do not know why it is not working. My application just stopped working when this part is being executed. Here is my code:</p>
  
  <p>ItemAnalysisRecord.java</p>
  
  <pre><code>package com.checkaidev1;
  
  import java.text.DecimalFormat;
  import java.util.ArrayList;
  import java.util.List;
  
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.ListView;
  import android.widget.TextView;
  
  public class ItemAnalysisRecord extends Activity {
  
      Context ctx = this;
      ListView listview1;
      DatabaseOperations dbOperations;
      List&lt;ItemAnalysis&gt; itemAnalysisList;
  
  
      BaseAdapter myAdapter = new BaseAdapter() {
  
          @Override
          public View getView(int position, View convertView, ViewGroup parent) {
              // TODO Auto-generated method stub
  
              if (convertView != null)
                  return convertView;
  
               LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
               View rowView = inflater.inflate(R.layout.item_analysis_row, parent, false);
  
               TextView itemNumberTextView = (TextView) rowView.findViewById(R.id.itemNumberTextView);
               itemNumberTextView.setText(getItemAnalysisData().get(position).getItemNumber());
               Log.i("Database Operations", "Evaluation: " + itemNumberTextView);
  
               TextView correctKeyTextView = (TextView) rowView.findViewById(R.id.correctKeyTextView);
               correctKeyTextView.setText(getItemAnalysisData().get(position).getCorrectKey());
               Log.i("Database Operations", "Evaluation: " + correctKeyTextView);
  
               TextView itemDifficultyTextView= (TextView) rowView.findViewById(R.id.itemDifficultyTextView);
               itemDifficultyTextView.setText(Double.toString(getItemAnalysisData().get(position).getItemDifficulty()));
               Log.i("Database Operations", "Evaluation: " + itemDifficultyTextView);
  
               TextView itemEvaluationTextView= (TextView) rowView.findViewById(R.id.itemEvaluationTextView);
               itemEvaluationTextView.setText(getItemAnalysisData().get(position).getEvaluation());
               Log.i("Database Operations", "Evaluation: " + itemEvaluationTextView);
  
               return rowView;
  
          }
  
          @Override
          public long getItemId(int arg0) {
              // TODO Auto-generated method stub
              return 0;
          }
  
          @Override
          public Object getItem(int arg0) {
              // TODO Auto-generated method stub
              return null;
          }
  
          @Override
          public int getCount() {
              // TODO Auto-generated method stub
             itemAnalysisList = getItemAnalysisData();
            return itemAnalysisList.size();
  
  
          }
      };
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.item_analysis_record);
         Log.i("CheckAide", "OnCreate Method Called");
  
          dbOperations = new DatabaseOperations(ctx);
  
         TextView examNameTextView = (TextView)findViewById(R.id.examNameTextView);
         examNameTextView.setText("Exam: " + dbOperations.getExam(ExamRecord.listviewIndex).getExamName());
         TextView examDateTextView = (TextView)findViewById(R.id.examDateTextView);
         examDateTextView.setText("Exam Date: " + dbOperations.getExam(ExamRecord.listviewIndex).getExamDate());
  
  
          listview1 = (ListView) findViewById(R.id.listview1);
  
          View header = (View)getLayoutInflater().inflate(R.layout.item_analysis_header, null);
          listview1.addHeaderView(header);
          listview1.setAdapter(myAdapter);
      }
  
      public List&lt;ItemAnalysis&gt; getItemAnalysisData()
      {
          int correctStudent = 0;
          String evaluation = null;
  
          List&lt;ItemAnalysis&gt; itemAnalysisList  = new ArrayList&lt;ItemAnalysis&gt;();
  
           int itemNumberCtr = dbOperations.getItemCount(ExamRecord.listviewIndex);
           int studentIDctr = dbOperations.getStudentCount(ExamRecord.listviewIndex);
  
  
           for(int x = 1; x &lt;= itemNumberCtr; x++)
           {
               ItemAnalysis itemAnalysis = new ItemAnalysis();
               itemAnalysis.setItemNumber(x);
               Log.i("Database Operations", "Item Number: " + x);
               String correctKey = dbOperations.getCorrectKey(ExamRecord.listviewIndex, x);
               itemAnalysis.setCorrectKey(correctKey);
               Log.i("Database Operations", "Correct Key: " + correctKey);
               for(int y = 1 ; y &lt;= studentIDctr; y++)
               {   
                   String answeredKey = dbOperations.getAnsweredKey(x, y);
                   Log.i("Database Operations", "Answered Key: " + answeredKey);
  
                   if (answeredKey.equalsIgnoreCase(correctKey))
                   {
                       correctStudent++;
                       Log.i("Database Operations", "CorrectStudent: " + correctStudent);
  
                   }
  
               }
               DecimalFormat df = new DecimalFormat("0.00");
               double itemDifficulty = Double.valueOf(df.format((double)correctStudent / (double)studentIDctr));
  
               itemAnalysis.setItemDifficulty(itemDifficulty);
               Log.i("Database Operations", "Correct Student: " + correctStudent + "StudentIDCtr:" + studentIDctr + "Item Difficulty " + itemDifficulty);
               correctStudent = 0;
           if (itemDifficulty &lt;= 0.20)
           {
               evaluation = "VD";
           }
           else if (itemDifficulty &lt;= 0.40 &amp;&amp; itemDifficulty &gt;= 0.21)
           {
               evaluation = "D";
           }
           else if (itemDifficulty &lt;= 0.60 &amp;&amp; itemDifficulty &gt;= 0.41)
           {
               evaluation = "MD";
           }
           else if (itemDifficulty &lt;= 0.80 &amp;&amp; itemDifficulty &gt;= 0.61)
           {
               evaluation = "E";
           }
           else if (itemDifficulty &lt;= 1.00 &amp;&amp; itemDifficulty &gt;= 0.81)
           {
               evaluation = "VE";
           }
  
           itemAnalysis.setEvaluation(evaluation);
           Log.i("Database Operations", "Evaluation: " + evaluation);
  
           itemAnalysisList.add(itemAnalysis);
           Log.i("Database Operations", "data added ");
  
           }
           return itemAnalysisList;
  
      }
  
  
  }
  </code></pre>
  
  <p>ItemAnalysis.java</p>
  
  <pre><code>package com.checkaidev1;
  
  public class ItemAnalysis {
      public int itemNumber;
      public String correctKey;
      public double itemDifficulty;
      public String evaluation;
  
      // Empty constructor
      public ItemAnalysis(){
  
      }
  
      public ItemAnalysis(int itemNumber, String correctKey, double itemDifficulty, String evaluation){
          this.itemNumber = itemNumber;
          this.correctKey = correctKey;
          this.itemDifficulty = itemDifficulty;
          this.evaluation = evaluation;
  
      }
  
      // getting name
      public int getItemNumber(){
          return this.itemNumber;
      }
  
      // setting name
      public void setItemNumber(int itemNumber){
          this.itemNumber = itemNumber;
      }
  
      // getting name
      public String getCorrectKey(){
          return this.correctKey;
      }
  
      // setting name
      public void setCorrectKey(String correctKey){
          this.correctKey = correctKey;
      }
  
      public double getItemDifficulty(){
          return this.itemDifficulty;
      }
  
      // setting name
      public void setItemDifficulty(double itemDifficulty){
          this.itemDifficulty = itemDifficulty;
      }
  
      public String getEvaluation(){
          return this.evaluation;
      }
  
      // setting name
      public void setEvaluation(String evaluation){
          this.evaluation = evaluation;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>I hope someone can help me solve this problem. Thanks in advance for the help.</p>