0

First off I need to tell you that I am new to java I have only been using it for a bout 3 weeks. I have am putting to gather a small app, this page (activity) has a bitmap image on it with 12 buttons each button is to invoke a different math equation, I have that bit working sofar. But have 3 problems, 1, the results TextView R.id.resultstextbox named = resultsText, dos not clear when a new button is pressed. I have tried declaring the TextView object as a global but get a runtime error. 2, the results are rounded and I need it to be 3 decimal places. 3, the buttons when placed over the bitmap image in graphical layout are all in the correct place, and this is also good when running in the emulator, but when testing on my phone the buttons have all moved, how do I fix this? I would appreciate any help I can get for this problem ? thanks

layout file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:paddingLeft="5dp"
    android:paddingRight="5dp" >

    <ImageView
        android:id="@+id/ohms_wheel_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginBottom="175dp"
        android:layout_marginTop="5dp"
        android:contentDescription="@string/ohms_wheel_image"
        android:src="@drawable/ohmslawwheel" />

    <Button
        android:id="@+id/button7"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/ohms_wheel_image"
        android:layout_marginRight="14dp"
        android:layout_toLeftOf="@+id/button6"
        android:text="Button" />

    <Button
        android:id="@+id/button9"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button4"
        android:layout_alignBottom="@+id/button4"
        android:layout_alignLeft="@+id/ohms_wheel_image"
        android:text="Button" />

    <Button
        android:id="@+id/button10"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignTop="@+id/button3"
        android:text="Button" />

    <Button
        android:id="@+id/button11"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button3"
        android:layout_alignLeft="@+id/entervoltstexlable"
        android:text="Button"
        android:textColor="@android:color/transparent" />

    <Button
        android:id="@+id/button8"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button7"
        android:layout_alignLeft="@+id/entervoltstexlable"
        android:text="Button" />

    <TextView
        android:id="@+id/resultstextbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/enterampslable"
        android:layout_alignParentBottom="true"
        android:layout_alignRight="@+id/button5"
        android:layout_marginBottom="34dp"
        android:clickable="false"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white" />

    <TextView
        android:id="@+id/displaytextbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/entervoltstexlable"
        android:layout_alignLeft="@+id/entervoltstexlable"
        android:layout_marginBottom="10dp"
        android:layout_toLeftOf="@+id/button4"
        android:clickable="false"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white" />

    <Button
        android:id="@+id/button3"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/button2"
        android:layout_marginTop="14dp"
        android:text="Button" />

    <Button
        android:id="@+id/button6"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button7"
        android:layout_alignBottom="@+id/button7"
        android:layout_alignRight="@+id/button1"
        android:text="Button" />

    <Button
        android:id="@+id/button4"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button3"
        android:layout_below="@+id/button3"
        android:text="Button" />

    <Button
        android:id="@+id/button5"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button6"
        android:layout_toRightOf="@+id/button6"
        android:text="Button" />

    <Button
        android:id="@+id/button12"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/button1"
        android:layout_alignBottom="@+id/button1"
        android:layout_toRightOf="@+id/button11"
        android:text="Button" />

    <TextView
        android:id="@+id/entervoltstexlable"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/enterampslable"
        android:layout_alignLeft="@+id/ohms_wheel_image"
        android:layout_alignParentEnd="false"
        android:layout_alignParentStart="false"
        android:layout_marginBottom="15dp"
        android:layout_marginLeft="14dp"
        android:clickable="false"
        android:text="@string/volts"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white" />

    <TextView
        android:id="@+id/enterampslable"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/resultstextbox"
        android:layout_alignLeft="@+id/entervoltstexlable"
        android:layout_marginBottom="14dp"
        android:clickable="false"
        android:text="@string/amps"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white" />

    <EditText
        android:id="@+id/editText2"
        android:layout_width="wrap_content"
        android:layout_height="35dp"
        android:layout_alignBaseline="@+id/enterampslable"
        android:layout_alignBottom="@+id/enterampslable"
        android:layout_alignLeft="@+id/enterampslable"
        android:layout_alignParentRight="false"
        android:layout_alignRight="@+id/ohms_wheel_image"
        android:layout_marginLeft="240dp"
        android:ems="10"
        android:height="25dp"
        android:inputType="number"
        android:textAppearance="?android:attr/textAppearanceSmall" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="wrap_content"
        android:layout_height="35dp"
        android:layout_alignBaseline="@+id/entervoltstexlable"
        android:layout_alignBottom="@+id/entervoltstexlable"
        android:layout_alignLeft="@+id/entervoltstexlable"
        android:layout_alignRight="@+id/editText2"
        android:layout_marginLeft="240dp"
        android:ems="10"
        android:gravity="center_vertical"
        android:height="25dp"
        android:inputType="number"
        android:textAppearance="?android:attr/textAppearanceSmall" >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/button1"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/ohms_wheel_image"
        android:layout_marginLeft="16dp"
        android:layout_marginTop="14dp"
        android:layout_toRightOf="@+id/button12"
        android:background="@android:color/transparent"
        android:text="@string/ohmsButton" />

    <Button
        android:id="@+id/button2"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignRight="@+id/button5"
        android:layout_alignTop="@+id/button1"
        android:layout_marginTop="22dp"
        android:background="@null"
        android:text="@string/ohmsButton"
        android:textColor="@android:color/transparent" />

</RelativeLayout>

Activity

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;



public class Ohms_Law extends Activity implements OnClickListener{

    long lg1 = 0;
    long lg2 = 0;
    long ans;
    EditText input1;
    EditText input2;
    int btnNo;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.ohms_wheel_page);

        //Find and define labels and display text box's
        //TextView resultsText = (TextView) findViewById(R.id.resultstextbox);

        input2 = (EditText) findViewById(R.id.editText2);
        //EditText input2 = (EditText) findViewById(R.id.editText2);
        input1 = (EditText) findViewById(R.id.editText1);

        input2.addTextChangedListener(new TextWatcher() {

        TextView resultsText = (TextView) findViewById(R.id.resultstextbox);


        @Override   
        public void afterTextChanged(Editable s) {

           }
         @Override
           public void beforeTextChanged(CharSequence s, int start,
             int count, int after) {
           }
         @Override
           public void onTextChanged(CharSequence s, int start,int before, int count) {

                //get user data

                String strValue1 = input1.getText().toString();
                String strValue2 = input2.getText().toString();

                try {
                    //convert to long
                    lg1 = Long.parseLong(strValue1);
                   // lg1 = Long.parseLong(getText(s));
                    lg2 = Long.parseLong(strValue2);

                }
                catch (NumberFormatException nfe)
                {
                    System.out.println("NumberFormatException: " + nfe.getMessage());
                }

                //Select which buttin pressed
                 switch(btnNo)
                 {
                 case 1:        

                     //test has anything been enterd
                     if(lg1 > 0 && lg2 > 0)
                    {               
                        //do math
                        ans = lg1 / lg2;
                    }
                    else
                    {
                        //Disply results
                        resultsText.setText("");
                    }
                    break;
                 case 2:
                     //test has anything been enterd
                     if(lg1 > 0 && lg2 > 0)
                    {               
                        //do math
                        ans = lg1 * lg2;
                    }
                     else
                        {
                            //Disply results
                            resultsText.setText("");
                        }
                     break;

                 }

                //results convert toString
                    Long.toString(ans);
                    String str = null;
                    str = str.valueOf(ans);

                    //Disply results
                    resultsText.setText("Results = " + str + " Volts");

           }
          });


        Button button1 = (Button) findViewById(R.id.button1);
        Button button2 = (Button) findViewById(R.id.button2);

        button1.setOnClickListener(this);
        button2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        TextView voltsText =(TextView) findViewById(R.id.entervoltstexlable);
        TextView ampsText = (TextView) findViewById(R.id.enterampslable);
        TextView displayText = (TextView) findViewById(R.id.displaytextbox);

        TextView resultsText2 = (TextView) findViewById(R.id.resultstextbox);

        switch(v.getId()){

            case R.id.button1:
                //Button id No
                btnNo = 1;

                //change  Calc Didplay
                displayText.setText("Power / Current = Volts");

                //chang display data
                voltsText.setText("Enter Power in Watts");
                //change  Calc Didplay
                //chang didplay text
                ampsText.setText("Enter Amps.");

                //clear results
            resultsText2.setText("");

               //Clear input text
               input1.setText("");
               input2.setText("");

               //Set focust to first edittext box
               input1.requestFocus();

                // math P/A (lg1 / lg2) = voltys
                break;
            case R.id.button2:
                //Button id No
                btnNo = 2;

                //change  Calc Didplay
                displayText.setText("Amps x ohms = Volts");

                //chang display data
                voltsText.setText("Emter Amps");
                //chang didplay text
                ampsText.setText("Enter Resistance in ohms.");

                //clear results
            resultsText2.setText("");

               //Clear input text
               input1.setText("");
               input2.setText("");

               //Set focust to first edittext box
               input1.requestFocus();
                //Math A*R = volts
                break;
            }                   
    }


}

enter image description here

codeMagic
  • 44,549
  • 13
  • 77
  • 93
buckau
  • 35
  • 2
  • 5
  • Regarding the textview not clearing, you should debug your app and make sure your `resultsText2.setText('')' line is getting called. For the rounding, see http://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java Regarding the buttons moving, I didn't look over your layout to be completely sure, but it's likely due to different screen density and size. – Reed Jul 02 '14 at 22:51
  • thanks for that i have fixed the rounding problem by changing the code to this [link] (//results convert toString String str = null; //reformat to 3 decimal places DecimalFormat f = new DecimalFormat("##.000"); str = f.format(ans); // double i2 = value * 2.23694; //i2 = Math.round(i2*1000000.0)/1000000.0; //Disply results resultsText.setText("Results = " + str + " Volts");) – buckau Jul 03 '14 at 21:58
  • resunltText2.setText("") i have checked the code and do not have any errors also the lines above and below all get acted on . – buckau Jul 03 '14 at 22:03
  • i reinstalled eclipse and the resunltText2.setText("") now seems to work. thanks any way – buckau Aug 20 '14 at 19:38

1 Answers1

0

As for the lay out problem i changed the layout to a table layout which worked OK. this is the XML layout if any one wont's to know how to do it.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ohms_wheel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black"
android:paddingRight="5dp"
android:paddingTop="5dp" >

<ImageView android:id="@+id/ohms_wheel_image"
    android:layout_width="wrap_content" android:layout_height="wrap_content"
    android:layout_alignParentLeft="true" android:layout_alignParentTop="true"
    android:layout_marginBottom="175dp" android:layout_marginTop="5dp"
    android:contentDescription="@string/ohms_wheel_image" android:src="@drawable/ohmslawwheel" />

<TableLayout android:id="@+id/tableLayout1"
    android:layout_width="fill_parent" android:layout_height="wrap_content">

    <TableRow
        android:id="@+id/tableRow1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button12"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="90dp"
            android:layout_marginTop="10dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

        <Button
            android:id="@+id/button1"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="80dp"
            android:layout_marginTop="10dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button11"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="60dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

        <Button
            android:id="@+id/button2"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="75dp"
            android:layout_marginRight="25dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow3"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp" >

        <Button
            android:id="@+id/button10"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="90dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

        <Button
            android:id="@+id/button3"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="100dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp" >

        <Button
            android:id="@+id/button9"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="90dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

        <Button
            android:id="@+id/button4"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="90dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow5"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp" >

        <Button
            android:id="@+id/button8"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20dp"
            android:layout_marginRight="50dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

        <Button
            android:id="@+id/button5"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="70dp"
            android:layout_marginRight="25dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

    </TableRow>

    <TableRow
        android:id="@+id/tableRow6"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:focusable="false" >

        <Button
            android:id="@+id/button7"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="90dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

        <Button
            android:id="@+id/button6"
            style="?android:attr/buttonStyleSmall"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15dp"
            android:layout_marginRight="80dp"
            android:background="@android:color/transparent"
            android:maxWidth="60dp"
            android:minHeight="40dp"
            android:minLines="1"
            android:text="@string/ohmsButton"
            android:textColor="@android:color/transparent"
            android:width="60dp" />

    </TableRow>

</TableLayout>

<TextView
    android:id="@+id/resultstextbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/enterampslable"
    android:layout_alignParentBottom="true"
    android:layout_alignRight="@+id/r2"
    android:layout_marginBottom="34dp"
    android:clickable="false"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/entervoltslable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/enterampslable"
    android:layout_alignLeft="@+id/ohms_wheel_image"
    android:layout_alignParentEnd="false"
    android:layout_alignParentStart="false"
    android:layout_marginBottom="15dp"
    android:layout_marginLeft="14dp"
    android:clickable="false"
    android:text="@string/volts"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/white" />

<EditText
    android:id="@+id/userInput2"
    android:layout_width="75dp"
    android:layout_height="37dp"
    android:layout_alignBaseline="@+id/enterampslable"
    android:layout_alignParentRight="true"
    android:layout_marginLeft="10dp"
    android:enabled="false"
    android:gravity="bottom|left"
    android:inputType="number"
    android:lines="1"
    android:maxLength="5"
    android:maxLines="1"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textSize="18sp" />

<TextView
    android:id="@+id/enterampslable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/resultstextbox"
    android:layout_alignLeft="@+id/entervoltslable"
    android:layout_marginBottom="14dp"
    android:clickable="false"
    android:text="@string/amps"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/white" />

<TextView
    android:id="@+id/displaytextbox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/entervoltslable"
    android:layout_alignLeft="@+id/entervoltslable"
    android:layout_alignRight="@+id/ohms_wheel_image"
    android:layout_marginBottom="10dp"
    android:clickable="false"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/white" />

<EditText
    android:id="@+id/userInput1"
    android:layout_width="75dp"
    android:layout_height="37dp"
    android:layout_alignBaseline="@+id/entervoltslable"
    android:layout_alignLeft="@+id/userInput2"
    android:layout_below="@+id/displaytextbox"
    android:layout_toRightOf="@+id/entervoltslable"
    android:enabled="false"
    android:gravity="bottom|left"
    android:inputType="number"
    android:lines="1"
    android:maxLength="5"
    android:maxLines="1"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textSize="18sp" >

    <requestFocus />
</EditText>

buckau
  • 35
  • 2
  • 5
  • for the results TextView R.id.resultstextbox named = resultsText, not clearing when a new button was pressed, I did a clean on the project but that did very little to fix ether of the problems, i was also having some problems with Eclipse so I reinstalled Ellipse and a lot of things improved with my Eclipse? the layout was better but still not good. the clearing of the results box was now working. – buckau Aug 21 '14 at 03:34
  • To fix the display problem i changed the XML layout as described above using a table layout and placed the buttons in the table rows and columns, this was difficult to set up but works well. On my landscape layout i have used a frame layout and placed a grid layout in it and then placed the buttons in the grid, this works well with the landscape layout. – buckau Aug 21 '14 at 03:34