Note that there are some explanatory texts on larger screens.

plurals
  1. POClear Edittext onclick issues
    primarykey
    data
    text
    <p>I'm kind of new to android programming and I've been searching for an answer to this for hours. I'm trying to get an <code>EditText</code> cleared when someone clicks on it, but for some reason eclipse isn't recognizing the <code>onClickListener</code>. What did I miss?</p> <pre><code> public class PillbugsStart extends Activity { private EditText text; private TextView f; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.pillbugsstart); text = (EditText) findViewById(R.id.editText1); text.setOnClickListener(this); } @Override public void onClick(View v) { editText.setText(""); f = (TextView) findViewById(R.id.grah); ImageButton b = (ImageButton)findViewById(R.id.testbutton2); b.setOnClickListener(new View.OnClickListener() { public void onClick(View argo) { Intent j = new Intent(PillbugsStart.this, Startpage.class); PillbugsStart.this.startActivity(j); } }); } public void myClickHandler(View view) { switch (view.getId()) { case R.id.FBLUB: RadioButton pounds = (RadioButton) findViewById(R.id.lbs); RadioButton kilograms = (RadioButton) findViewById(R.id.kilograms); if (text.getText().length() == 0) { Toast.makeText(this, "Please enter a valid number", Toast.LENGTH_LONG).show(); return; } float inputValue = Float.parseFloat(text.getText().toString()); if (pounds.isChecked()) { f.setText(String.valueOf(convertFromPounds(inputValue))); pounds.setChecked(true); } else { f.setText(String.valueOf(convertFromKilograms(inputValue))); } break; } } private float convertFromPounds(float pounds) { return ((pounds * 454) * 1/2); } private float convertFromKilograms(float kilograms) { return ((kilograms * 1000) * 1/2); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload