0
我試圖使用在列表中選擇聽者的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);
}
如果您想在SpinnerActivity中處理所選值,請嘗試使用startActivityForResult調用它並處理結果以設置edt的可見性。它只顯示一個活動,所以你想改變它的Viewstate? –