私はAndroidプログラミングの新機能で、これに対する答えを何時間も探してきました。誰かがクリックしたときに私はEditText
をクリアしようとしていますが、何らかの理由でEclipseがonClickListener
を認識していません。 私は何を欠席しましたか?Edittext onclickの問題をクリアする
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);
}
}
のテキストのonClick明らか
..
EditText
の上に表示されますとマイナーな調整で見栄えの良い行うことができますこのListnerを認識しません。 –