title: How to program a button to export table layout to image or PDF file on android app
body: <p>I feel like I've looked everywhere and I still don't know how to accomplish my goal.  I have an android app that I made with Eclipse, and it has a table layout within a linear layout.  The table does some calculations and provides answers like an excel spreadsheet.  The link to my app is below.  I simply want to add a button to export to an image file that can be stored on the SD drive, that, or a PDF file.  I thought it would be simple, but I'm completely lost here.  I am new to programming, but the app has close to 500 downloads now, and I've had a request to add this function.  I made the activity display in XML.  Thanks for helping.
  ![enter image description here][1]</p>
  
  <p><a href="https://play.google.com/store/apps/details?id=com.bestserialdilutioncalculator&amp;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5iZXN0c2VyaWFsZGlsdXRpb25jYWxjdWxhdG9yIl0" rel="nofollow">https://play.google.com/store/apps/details?id=com.bestserialdilutioncalculator&amp;feature=search_result#?t=W251bGwsMSwxLDEsImNvbS5iZXN0c2VyaWFsZGlsdXRpb25jYWxjdWxhdG9yIl0</a>.</p>
  
  <p>So I already have the button made in XML (JPEGB), as you can see further below. In Java code I haven't yet added anything related to this button or to the exporting to image.  The "Button Calculate" is for a different purpose, and is referred to later on in the code.  So basically, this is starting from scratch in the Java code, with a simple button made in XML.  I truncated the code where I considered it unnecessary for this post.  Thanks so much!! </p>
  
  <p>Java Code</p>
  
  <pre><code>package com.example.bestserialdilutioncalculator;
  
  import java.math.BigDecimal;
  import java.math.RoundingMode;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  
  import com.bestserialdilutioncalculator.R;
  
  
  
  public class InitialLayout extends Activity {
  
  Button Calculate;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_table_calculator);
  </code></pre>
  
  <p>XML for Layout</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:orientation="horizontal" &gt;
  
  &lt;RelativeLayout 
      android:orientation="vertical"
      android:background="#000000"
      android:layout_width="42dp"
      android:layout_height="fill_parent"&gt;
      &lt;View
          android:layout_width="25dp"
          android:layout_centerHorizontal="true"
          android:background="@drawable/customicon"
          android:layout_height="25dp"
          &gt;&lt;/View&gt;
  
      &lt;Button
          android:id="@+id/CalculateButton"
          android:layout_width="match_parent"
          android:layout_height="200dp"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:layout_marginTop="55dp"
          android:background="@drawable/goodbutton"
          android:text=" " /&gt;
  
      &lt;Button
          android:id="@+id/JPEGB"
          android:layout_width="match_parent"
          android:layout_height="28dp"
          android:layout_centerHorizontal="true"
          android:layout_alignParentBottom="true"
          android:background="@drawable/jpegbutton"/&gt;
  
  &lt;/RelativeLayout&gt;
  
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/ScrollerForTable"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:fillViewport="true"
      android:background="#000000" &gt;
  
    &lt;HorizontalScrollView
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/HorizontalScrollerForTable"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#000000"&gt;
  
  &lt;TableLayout
      android:id="@+id/Table"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:background="#000000" &gt;
  </code></pre>
  
  <p>rest of code is table layout details, and is very long.</p>