Search Results

Search found 2 results on 1 pages for 'andyfan'.

Page 1/1 | 1 

  • What's wrong in this simple android Program, I get 'Force Close'.

    - by andyfan
    What is wrong in this program, My eclipse IDE doesn't show any errors....when I execute this simple program the emulator shows force close....Anybody please clarify import android.app.Activity; import android.view.View.OnClickListener; import android.view.View; import android.os.Bundle; import android.widget.*; public class HelloWorld extends Activity implements OnClickListener { /** Called when the activity is first created. */ View Et1,Bt1,TxtDisp; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.name_getter); Bt1=(Button)findViewById(R.id.Btn1); Et1=(EditText)findViewById(R.id.UserInput); TxtDisp=(TextView)findViewById(R.id.TextDisp); Bt1.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub String userInput=((EditText) Et1).getText().toString(); ((TextView)TxtDisp).setText(userInput); } }

    Read the article

  • How to restrict this function from execution in android? Please help

    - by andyfan
    This code is present in one of this activity. I want to restrict addJoke() function from executing if the String variable new_joke is null, has no text or contains just spaces. Here is code protected void initAddJokeListeners() { // TODO m_vwJokeButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { //Implement code to add a new joke here... String new_joke=m_vwJokeEditText.getText().toString(); if(new_joke!=null&&new_joke!=""&&new_joke!=" ") { addJoke(new_joke); } } }); } I don't know why addJoke() function is getting executed even I don't enter any text in EditText field. Please help.

    Read the article

1