4

我正在尝试制作一个基于选项卡的应用程序,它是一个学校调度应用程序。

我在 activitiy_main.xml 中使用 tabhost 来使用所有数据(设置选项卡名称、元素等)。

我想要做的是有一个微调器(位于我的 tabhost 的 tab3 中)指示它下面显示的选项。

我有多个要展示的选项。

这是位于我的 activity_main_xml 中的 tab3 的 XML 布局:

`

      <TextView
          android:id="@+id/labelAdd"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/add"
          android:textAppearance="?android:attr/textAppearanceLarge" />

      <Spinner
          android:id="@+id/addDropDown"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:entries="@array/type_array" />

      <Button
          android:id="@+id/StartTimeButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/addStartTime" />

      <TextView
          android:id="@+id/startTimeLabel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/addStartTime" />

      <TimePicker
          android:id="@+id/startTimePicker"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />

      <TextView
          android:id="@+id/endTimeLabel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/addEndTime" />

      <TimePicker
          android:id="@+id/endTimePicker"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" />

      <TextView
          android:id="@+id/addRepeatQ"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/addRepeatQ" />

      <RadioGroup
          android:id="@+id/repeatRadioGroup"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" >

          <RadioButton
              android:id="@+id/addRepeatN"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:checked="true"
              android:text="@string/addRepeatN" />

          <RadioButton
              android:id="@+id/addRepeatY"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/addRepeatY" />
      </RadioGroup>

      <Button
          android:id="@+id/addNextButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/addNext" />

  </LinearLayout>`

我想让某些项目,特别是 startTimeLabel、StartTimeButton、endTimeLabel、endTimeButton 仅在选择我的微调器的某个元素时显示(在这种情况下,选择的项目将标题为“类”)。

有关如何开始构建我的 .java 的任何帮助?我是 Android 编程新手,但在 java、html、php、sql 和 Visual Studio 方面有经验。

4

1 回答 1

0
urSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int arg2, long arg3) 
        {
            //write your code here what you want
                      change visibility of your Views(buttons,textviews) etc

        }

        public void onNothingSelected(AdapterView<?> arg0) {


        }
    });

如果你得到这个想法,请把它作为答案

于 2013-02-12T07:40:28.617 回答