我试图在列表选择侦听器中使用edittext,但它无法从主要活动中看到它,这让我出错
edt.setVisibility(View.VISIBLE);
所以请如果你有什么帮助我
public class MainActivity extends Activity {
static int HELLO_ID = 1;
boolean flag = false;
CountDownTimer timer;
//the strings of the notifications
String titlePills = "Time to take Panadol",DescriptionPills = "Panadol";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Spinner spinner = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.planets_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new SpinnerActivity());
Chronometer test = new Chronometer(this);
Button btn = (Button)findViewById(R.id.button1);
EditText edt = (EditText)findViewById(R.id.editText1);
//hide the button and the edit text
btn.setVisibility(View.GONE);
edt.setVisibility(View.GONE);
}
//*********************************************************************************
public class SpinnerActivity extends Activity implements OnItemSelectedListener {
public void onItemSelected(final AdapterView<?> parent, View view,
int pos, long id) {
String select = parent.getItemAtPosition(pos).toString();
if(select.equals("Type the timee"))
{
//edt error can't be resolved
edt.setVisibility(View.VISIBLE);
}