Thanks for the reply,, my log ineclipse is showing the else statement of that number is not recognized. I need to work on my if statement, and to display the responding if statement or else statement on screen.
On Feb 22, 9:25 pm, Pavel Dudka <[email protected]> wrote: > Really funny, but anyways... > > 1) You cannot do " if (PleaseEnter.equals("1")) " > If you want to get String which was entered by user - you need to use > PleaseEnter.getText() method, so your if statement would probably look > like: > if(PleaseEnter.getText().equals("1")) > { > tv.setText("This is the display 1"); > > } > > 2) As I understand, you are experiencing problems when trying to > return something from onClick() - don't do that :) You don't need it - > believe me :) > > On Feb 22, 5:10 pm, Pram <[email protected]> wrote: > > > > > > > > > The code is below I have taken out some of the commented parts that > > were above. > > public class GenNameActivity extends Activity { > > EditText PleaseEnter; > > > /** Called when the activity is first created. */ > > @Override > > protected void onCreate(Bundle savedInstanceState) { > > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > Button button = (Button)findViewById(R.id.go); > > button.setOnClickListener(mAddListener); > > } > > > private OnClickListener mAddListener = new OnClickListener() > > { > > public void onClick(View v) > > { > > > Toast.makeText(Num.this,stringFunction(),Toast.LENGTH_SHORT).show(); > > } > > Public string stringFunction(); > > { > > { > > PleaseEnter=(EditText)findViewById(R.id.PleaseEnter); > > > { > > } > > > if (PleaseEnter.equals("1")) { > > //tv.setText("This is the display 1."); > > return "9"; > > } else if (PleaseEnter.equals("2")){ > > //return; > > > On Feb 22, 7:37 pm, "Tommy Hartz" <[email protected]> wrote: > > > > Copy and paste the code so I can see exactly what you have. > > > > -----Original Message----- > > > From: [email protected] > > > > [mailto:[email protected]] On Behalf Of Pram > > > Sent: Wednesday, February 22, 2012 5:47 PM > > > To: Android Developers > > > Subject: [android-developers] Re: Button for dynamic text > > > > At publicstring stringFunction(){ > > > I am getting syntax error need ; to complete Field Decleration. > > > > On Feb 22, 3:39 pm, "Tommy Hartz" <[email protected]> wrote: > > > > Why not connect the button click event to a function EX > > > > > public void onClick(View v) { > > > > > Toast.makeText(Num.this, stringFunction(),Toast.LENGTH_SHORT).show(); > > > > > } > > > > > Public string stringFunction(){ > > > > > If(whatever){ > > > > > Return = "Hello"; > > > > > } > > > > } > > > > > From: [email protected] > > > > [mailto:[email protected]] On Behalf Of TreKing > > > > Sent: Wednesday, February 22, 2012 3:22 PM > > > > To: [email protected] > > > > Subject: Re: [android-developers] Re: Button for dynamic text > > > > > On Wed, Feb 22, 2012 at 2:13 PM, Pram <[email protected]> wrote: > > > > > when I try to use return in my if statement that does not work the tv > > > > statements do not show anything on the screen when it is executed. > > > > > The code in your original post is extremely hard to read. Try a > > > > smaller snippet that illustrates what you're talking about. > > > > > Have you put in logging and used your debugger to step through and see > > > > what the code is doing? > > > > > ---------------------------------------------------------------------- > > > > ------ > > > > --------------------- > > > > TreKing <http://sites.google.com/site/rezmobileapps/treking> - > > > > Chicago transit tracking app for Android-powered devices > > > > > -- > > > > You received this message because you are subscribed to the Google > > > > Groups "Android Developers" group. > > > > To post to this group, send email to > > > > [email protected] > > > > To unsubscribe from this group, send email to > > > > [email protected] > > > > For more options, visit this group > > > > athttp://groups.google.com/group/android-developers?hl=en > > > > -- > > > You received this message because you are subscribed to the Google Groups > > > "Android Developers" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group > > > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

