Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I'm so glad I found this site... Now I can get some sleep, because my problem is solved..."

Geography

Where in the world do Tek-Tips members come from?
Hfnet (IS/IT--Management)
4 Aug 11 8:04
Hi,

I am new to Eclipse programming and have a question. I have a main.xml which has a number of textViews and other information. I have a menu on which one button is "Save to PDF". When the button is tapped I need to get the textViews and a canvas image into a PDF.

I have worked out most of this, except that I cannot get the information from the form. If I try and call info from R.id.textView4 it complains of retrieving static code from a non-static field.

I have tried several things, including putting the PDF code into a separate class and using an intent, but have made no progress there either.

Could someone point me to a tutorial on calling class files and retrieving information from main.xml, or show me a simple code snippet of getting the data if putting the code in app.java?
Hfnet (IS/IT--Management)
5 Aug 11 2:38
Thought I would post the code I am using. Now getting no error but also the textView4 data is not pulled in. (textView4 is a textview with autocomplete):

@Override
       public boolean onOptionsItemSelected(MenuItem item) {
           switch (item.getItemId()) {
                        
         case R.id.SavetoPDF:
             //save to PDF
                
             Toast.makeText(this, "Generating PDF", Toast.LENGTH_SHORT).show();
    
             try {
                 Document document = new Document();
                 PdfWriter.getInstance(document, new FileOutputStream(FILE));
                 document.open();
                 addMetaData(document);
                 addTitlePage(document);
                 addContent(document);
                 document.close();
             } catch (Exception e) {
                 e.printStackTrace();
             }
             return true;
             
       }



private void addTitlePage(Document document)
            throws DocumentException {
        
        TextView clName = (TextView) findViewById(R.id.textView4);

        Paragraph preface = new Paragraph();
        preface.setAlignment(Element.ALIGN_CENTER);
        // add one empty line
        addEmptyLine(preface, 1);
        // header
        preface.add(new Paragraph("Timesheet", catFont));

        addEmptyLine(preface, 1);
        
        preface.add(new Paragraph(
                "Customer Details: ",
                smallBold));
        
        addEmptyLine(preface, 1);

    preface.add(new Paragraph(
                (String) clName.getText().toString(),
                smallBold));
        preface.add(new Paragraph(
                "This is where the address will go: ",
                smallBold));
        
        

        document.add(preface);
        // Start a new page
        document.newPage();
    }
Hfnet (IS/IT--Management)
5 Aug 11 13:14
Figured it out:

String ETValue = ((TextView) findViewById(R.id.autocomplete_client)).getText().toString();

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close