title: MPAndroidChart -get the value of x entry
body: <p>I want to get the values for the x entry which is a string when clicked on a sector of pie. how? I can get y value using getVal(), but how about x? The value for x axis entry is from sqlite. The code are as shown below</p>
  
  <pre><code>public class chart extends Activity {
  
  private FrameLayout chartContainer;
  private PieChart mChart;
  
  Context CTX = this;
  DatabaseOperations DOP;
  
  @Override
  protected void onCreate (Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.chart);
      chartContainer=(FrameLayout) findViewById(R.id.chartContainer);
      mChart=new PieChart(this);
      //add pie chart to the layout
      chartContainer.addView(mChart);
  
      //enable hole and configure
      mChart.setDrawHoleEnabled(true);
      mChart.setHoleColorTransparent(true);
  
      mChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
          @Override
          public void onValueSelected(Entry e, int dataSetIndex, Highlight h) {                if (e == null)
                  return;
              Toast.makeText(chart.this, xVals.get(e.getXIndex()) + " used " + e.getVal() + "kwh", Toast.LENGTH_SHORT).show();
          }
  
          @Override
          public void onNothingSelected() {
  
          }
      });
  
      //add data
      addeachData();
  
      Legend l=mChart.getLegend();
      l.setPosition(Legend.LegendPosition.RIGHT_OF_CHART);
  }
  
  protected void addeachData() {
      DatabaseOperations DOP = new DatabaseOperations(CTX);
      Cursor CR = DOP.getInformation(DOP);
      int count=CR.getCount();
  
      float[]values=new float[count];
      String[]name=new String[count];
  
      for (int m=0; m&lt;count; m++){
          CR.moveToNext();
          name[m]=CR.getString(0);
          values[m]=CR.getFloat(1);
      }
      ArrayList&lt;Entry&gt; yVals = new ArrayList&lt;Entry&gt;();
  
      for (int i = 0; i &lt;name.length; i++)
          yVals.add(new Entry(values[i], i));
  
      final ArrayList&lt;String&gt; xVals = new ArrayList&lt;String&gt;();
  
      for (int i = 0; i &lt;name.length; i++)
          xVals.add(name[i]);
  
      ArrayList&lt;Integer&gt; colors=new ArrayList&lt;Integer&gt;();
      for(int c: ColorTemplate.VORDIPLOM_COLORS)
          colors.add(c);
      colors.add(ColorTemplate.getHoloBlue());
      dataSet.setColors(colors);
  
      PieData data=new PieData(xVals, dataSet);
      data.setValueFormatter(new PercentFormatter());
      data.setValueTextSize(11f);
      data.setValueTextColor(Color.GRAY);
  
      mChart.setData(data);
      mChart.highlightValues(null);
      mChart.invalidate();
  }
  </code></pre>
  
  <p>}</p>