In my android app it will create a pie chart when a button is clicked. This is my code segment for button clicked.

```
btnpieChart.setOnClickListener(new OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        SelectDBAdapter selectDBAdapter = SelectDBAdapter
                                .getDBAdapterInstance(getActivity());
                        try {
                            selectDBAdapter.openDataBase();
                            chartDataMap = selectDBAdapter.getPieChartData(strBusinessUnit,
                                    currentPeriod, currentYear);
                        } catch (Exception e) {
                            selectDBAdapter.close();
                            e.printStackTrace();
                        } finally {
                            selectDBAdapter.close();
                        }
                        if (chartDataMap.size() > 0) {
                            Intent chrtIntent = new Intent(getActivity(),
                                    PieChart.class);
                            chrtIntent.putExtra("chartMap", chartDataMap);
                            startActivity(chrtIntent);
                        } else {
                            Toast.makeText(getActivity(), "No Achievement Progress", Toast.LENGTH_SHORT).show();
                        }

                    }
                });

```

And this is my PieChart.java class.

```
package xont.virtusel.v4.controller;

//imports

public class PieChart extends Activity {
private ArrayList<String> lstBrandNames = new ArrayList<String>();
private ArrayList<Double> lstAchievedVals = new ArrayList<Double>();
private GraphicalView mChartView = null;

protected void onResume() {
    super.onResume();
}

public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}

public void onBackPressed() {
    return;
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        this.finish();

        return true;
    }
    return false;

}

public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.complains, menu);
    return true;
}

public boolean onOptionsItemSelected(android.view.MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_cancel:
        this.finish();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pie_chart);

    HashMap<String, Double> chrtMap = (HashMap<String, Double>) getIntent().getSerializableExtra("chartMap");
        for (Map.Entry<String, Double> entry : chrtMap.entrySet()) {
            //System.out.println(">>>> " + entry.getValue());
            if (entry.getValue() > 0) {
                lstBrandNames.add(entry.getKey());
                lstAchievedVals.add(entry.getValue());
            }
        }

        if (lstBrandNames.size() == 0 || lstAchievedVals.size() == 0) {
            Toast.makeText(getApplicationContext(), "No Achievement Progress", Toast.LENGTH_SHORT).show();
            finish();
        } else {

            ArrayList<Double> distribution = calc_Percentage(lstAchievedVals);
            System.out.println("distribution === " + distribution);
            lstBrandNames = set_lables(lstBrandNames, distribution);

            CategorySeries distributionSeries = new CategorySeries(
                    "Your Achievement Progress");
            for (int i = 0; i < distribution.size(); i++) {
                distributionSeries.add(lstBrandNames.get(i),
                        distribution.get(i));
            }

            DefaultRenderer defaultRenderer = new DefaultRenderer();
            defaultRenderer.setApplyBackgroundColor(true);
            defaultRenderer.setBackgroundColor(Color.WHITE);
            defaultRenderer.setLabelsTextSize(15);
            defaultRenderer.setInScroll(true);

            for (int i = 0; i < distribution.size(); i++) {

                SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();
                Random rnd = new Random();
                int color = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256),
                        rnd.nextInt(256));
                seriesRenderer.setColor(color);
                seriesRenderer.setDisplayChartValues(true);
                seriesRenderer.setShowLegendItem(false);
                defaultRenderer.addSeriesRenderer(seriesRenderer);

            }

            defaultRenderer.setLabelsColor(Color.BLACK);
            defaultRenderer.setChartTitle("Your Achievement Progress");
            defaultRenderer.setChartTitleTextSize(25);
            defaultRenderer.setZoomButtonsVisible(true);
            defaultRenderer.setShowLabels(true);

            mChartView = ChartFactory.getPieChartView(this,
                    distributionSeries, defaultRenderer);
            LinearLayout layout = (LinearLayout) findViewById(R.id.chart_container);
            layout.removeAllViews();
            layout.addView(mChartView);
        }
}

public static ArrayList<Double> calc_Percentage(ArrayList<Double> list) {

    ArrayList<Double> lstPercentage = new ArrayList<Double>();

    double total = 0;
    double precentage;
    for (int i = 0; i < list.size(); i++) {
        total = total + list.get(i);
    }
    System.out.println(total);
    for (int j = 0; j < list.size(); j++) {
        precentage = (list.get(j) / total) * 100;
        lstPercentage.add(precentage);
    }

    return lstPercentage;
}

public static ArrayList<String> set_lables(ArrayList<String> lstBrandNames,
        ArrayList<Double> distribution) {
    String G_lable;
    DecimalFormat df = new DecimalFormat("#.00");
    ArrayList<String> lstLabels = new ArrayList<String>();
    for (int i = 0; i < lstBrandNames.size(); i++) {
        G_lable = lstBrandNames.get(i) + " : "
                + df.format(distribution.get(i)) + "%";
        lstLabels.add(G_lable);
    }
    return lstLabels;

}

```

}

Here is my pie\_chart.xml file.

I want to disable the default Back key function of the device and introduce the close button on top of the pic chart. I've added a menu in my PieChart class but no luck. Why it is not adding the menu like other activities? I've introduced my pie chart class in manifest file as follows.

```
<activity android:name=".PieChart" android:theme="@android:style/Theme.Dialog"  android:label="Progress Chart"> </activity>

```

How should I solve this issue ? Any suggestions are greatly appreciated.