Multiple intent depends on radio button selected
up vote
-1
down vote
favorite
It is possible to go to specific class base on what radio button selected?
And it is possible to make an if-else statement in onClick for the new intent?
For example,
Circle, Square, Triangle radio group button.
Circle has been selected.
In "onClick"
There is a if-else statement that has "circle.class", "square.class", "triangle.class"
The intent will go to "circle.class"
java
add a comment |
up vote
-1
down vote
favorite
It is possible to go to specific class base on what radio button selected?
And it is possible to make an if-else statement in onClick for the new intent?
For example,
Circle, Square, Triangle radio group button.
Circle has been selected.
In "onClick"
There is a if-else statement that has "circle.class", "square.class", "triangle.class"
The intent will go to "circle.class"
java
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
It is possible to go to specific class base on what radio button selected?
And it is possible to make an if-else statement in onClick for the new intent?
For example,
Circle, Square, Triangle radio group button.
Circle has been selected.
In "onClick"
There is a if-else statement that has "circle.class", "square.class", "triangle.class"
The intent will go to "circle.class"
java
It is possible to go to specific class base on what radio button selected?
And it is possible to make an if-else statement in onClick for the new intent?
For example,
Circle, Square, Triangle radio group button.
Circle has been selected.
In "onClick"
There is a if-else statement that has "circle.class", "square.class", "triangle.class"
The intent will go to "circle.class"
java
java
asked 17 hours ago
Skiwmish
135
135
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Yes it is very much possible!
All ya gotta do is call the mainn method of the required class(or any other method)
If the method is static,call it directly through class reference, it it is non-static then use an object of that class(take care of the NullPointerException though)
1)Make sure your circle or triangle(or whatever) classes are created
Either you can :
Under the ActionPerformed() event for jRadioButton1
// should be the name of your button, say CircleActionPerformed()
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
if(jRadioButton.isSelected() == true)
circle.main() //
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Yes it is very much possible!
All ya gotta do is call the mainn method of the required class(or any other method)
If the method is static,call it directly through class reference, it it is non-static then use an object of that class(take care of the NullPointerException though)
1)Make sure your circle or triangle(or whatever) classes are created
Either you can :
Under the ActionPerformed() event for jRadioButton1
// should be the name of your button, say CircleActionPerformed()
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
if(jRadioButton.isSelected() == true)
circle.main() //
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
add a comment |
up vote
0
down vote
Yes it is very much possible!
All ya gotta do is call the mainn method of the required class(or any other method)
If the method is static,call it directly through class reference, it it is non-static then use an object of that class(take care of the NullPointerException though)
1)Make sure your circle or triangle(or whatever) classes are created
Either you can :
Under the ActionPerformed() event for jRadioButton1
// should be the name of your button, say CircleActionPerformed()
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
if(jRadioButton.isSelected() == true)
circle.main() //
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
add a comment |
up vote
0
down vote
up vote
0
down vote
Yes it is very much possible!
All ya gotta do is call the mainn method of the required class(or any other method)
If the method is static,call it directly through class reference, it it is non-static then use an object of that class(take care of the NullPointerException though)
1)Make sure your circle or triangle(or whatever) classes are created
Either you can :
Under the ActionPerformed() event for jRadioButton1
// should be the name of your button, say CircleActionPerformed()
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
if(jRadioButton.isSelected() == true)
circle.main() //
Yes it is very much possible!
All ya gotta do is call the mainn method of the required class(or any other method)
If the method is static,call it directly through class reference, it it is non-static then use an object of that class(take care of the NullPointerException though)
1)Make sure your circle or triangle(or whatever) classes are created
Either you can :
Under the ActionPerformed() event for jRadioButton1
// should be the name of your button, say CircleActionPerformed()
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
if(jRadioButton.isSelected() == true)
circle.main() //
answered 13 hours ago
Siddharth Bhat
25
25
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
add a comment |
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
By the Way, is OnClick a Button or what?
– Siddharth Bhat
13 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
OnClick a button sir. I tried like this "if ("Circle".equals(radioButton.getText().toString()))" but the error "Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference at com.example.locator.myapplication.MainActivity$3.onClick(MainActivity.java:87)"
– Skiwmish
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Try using the isSelected()== true instead of getText().
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
Also check if your button name is correct
– Siddharth Bhat
7 hours ago
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237307%2fmultiple-intent-depends-on-radio-button-selected%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password