Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two number pickers Numberpicker1 and Numberpicker2
Numberpicker 1 => numberpicker1.setminvalue(1) and numberpicker1.setmaxvalue(7)
Numberpicker 2 => numberpicker2.setminvalue(0) and numberpicker2.setmaxvalue(12)


My design code

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerInParent="true"
    android:id="@+id/layout1"
    >
    <NumberPicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/picker1"
        android:layout_marginRight="20dp"
        android:layout_marginEnd="20dp"></NumberPicker>


    <NumberPicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/picker2"
        ></NumberPicker>
</LinearLayout>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/layout1"
    android:text="SUBMIT"
    android:layout_centerInParent="true"
    android:layout_margin="10dp"
    />



My Mainactivity Code

public class MainActivity extends AppCompatActivity {
NumberPicker pick1,pick2;
Button btnsubmit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        pick1 = (NumberPicker)findViewById(R.id.picker1);
        pick2 = (NumberPicker)findViewById(R.id.picker2);

        pick1.setMinValue(1);
        pick1.setMaxValue(7);
        pick2.setMinValue(0);
        pick2.setMaxValue(12);

        btnsubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v)
            {
                try
                {

                }
                catch (Exception e)
                {
                    e.getMessage();
                }
            }
        });

    }
}


What I have tried:

The output is not showing displaying unfortunately stopped app gets crashed
pls help out.And even my onclick button code is not working error i am unable to rectify.i dont have much knowledge about coding pls correct my code and send here
Posted
Updated 31-Aug-18 22:28pm
v2
Comments
David Crow 2-Sep-18 19:56pm    
"The output is not showing displaying unfortunately stopped app gets crashed"

This is not very helpful.

"And even my onclick button code is not working..."

So what happens when you step through that code using the debugger?

1 solution

Why have you reposted this question? I gave you the answer yesterday at https://www.codeproject.com/Questions/1258508/How-to-add-two-number-picker-values[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900