我正在尝试制作一个基于选项卡的应用程序,它是一个学校日程安排应用程序。
我在 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 方面的经验。
最佳答案
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) {
}
});
如果你明白了,请把它作为答案
关于android - 根据选择微调器的哪个元素更改选项卡内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14542107/
如何正确创建Rails迁移,以便将表更改为MySQL中的MyISAM?目前是InnoDB。运行原始执行语句会更改表,但它不会更新db/schema.rb,因此当在测试环境中重新创建表时,它会返回到InnoDB并且我的全文搜索失败。我如何着手更改/添加迁移,以便将现有表修改为MyISAM并更新schema.rb,以便我的数据库和相应的测试数据库得到相应更新? 最佳答案 我没有找到执行此操作的好方法。您可以像有人建议的那样更改您的schema.rb,然后运行:rakedb:schema:load,但是,这将覆盖您的数据。我的做法是(假设
我需要读入一个包含数字列表的文件。此代码读取文件并将其放入二维数组中。现在我需要获取数组中所有数字的平均值,但我需要将数组的内容更改为int。有什么想法可以将to_i方法放在哪里吗?ClassTerraindefinitializefile_name@input=IO.readlines(file_name)#readinfile@size=@input[0].to_i@land=[@size]x=1whilex 最佳答案 只需将数组映射为整数:@land边注如果你想得到一条线的平均值,你可以这样做:values=@input[x]
我在我的Rails项目中使用Pow和powifygem。现在我尝试升级我的ruby版本(从1.9.3到2.0.0,我使用RVM)当我切换ruby版本、安装所有gem依赖项时,我通过运行railss并访问localhost:3000确保该应用程序正常运行以前,我通过使用pow访问http://my_app.dev来浏览我的应用程序。升级后,由于错误Bundler::RubyVersionMismatch:YourRubyversionis1.9.3,butyourGemfilespecified2.0.0,此url不起作用我尝试过的:重新创建pow应用程序重启pow服务器更新战俘
我尝试使用不同的ssh_options在同一阶段运行capistranov.3任务。我的production.rb说:set:stage,:productionset:user,'deploy'set:ssh_options,{user:'deploy'}通过此配置,capistrano与用户deploy连接,这对于其余的任务是正确的。但是我需要将它连接到服务器中配置良好的an_other_user以完成一项特定任务。然后我的食谱说:...taskswithoriginaluser...task:my_task_with_an_other_userdoset:user,'an_othe
我是一个Rails初学者,但我想从我的RailsView(html.haml文件)中查看Ruby变量的内容。我试图在ruby中打印出变量(认为它会在终端中出现),但没有得到任何结果。有什么建议吗?我知道Rails调试器,但更喜欢使用inspect来打印我的变量。 最佳答案 您可以在View中使用puts方法将信息输出到服务器控制台。您应该能够在View中的任何位置使用Haml执行以下操作:-puts@my_variable.inspect 关于ruby-on-rails-如何在我的R
我有一个用户工厂。我希望默认情况下确认用户。但是鉴于unconfirmed特征,我不希望它们被确认。虽然我有一个基于实现细节而不是抽象的工作实现,但我想知道如何正确地做到这一点。factory:userdoafter(:create)do|user,evaluator|#unwantedimplementationdetailshereunlessFactoryGirl.factories[:user].defined_traits.map(&:name).include?(:unconfirmed)user.confirm!endendtrait:unconfirmeddoenden
我正在尝试解析一个CSV文件并使用SQL命令自动为其创建一个表。CSV中的第一行给出了列标题。但我需要推断每个列的类型。Ruby中是否有任何函数可以找到每个字段中内容的类型。例如,CSV行:"12012","Test","1233.22","12:21:22","10/10/2009"应该产生像这样的类型['integer','string','float','time','date']谢谢! 最佳答案 require'time'defto_something(str)if(num=Integer(str)rescueFloat(s
假设我有一个FireNinja我的数据库中的对象,使用单表继承存储。后来才知道他真的是WaterNinja.将他更改为不同的子类的最干净的方法是什么?更好的是,我很想创建一个新的WaterNinja对象并替换旧的FireNinja在数据库中,保留ID。编辑我知道如何创建新的WaterNinja来self现有FireNinja的对象,我也知道我可以删除旧的并保存新的。我想做的是改变现有项目的类别。我是通过创建一个新对象并执行一些ActiveRecord魔法来替换行,还是通过对对象本身做一些疯狂的事情,或者甚至通过删除它并使用相同的ID重新插入来做到这一点,这是问题的一部分。
状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串。我已经测试了一个看起来很漂亮但效果不佳的。它是“挑剔的颜色”,并托管在此存储库中:https://github.com/Astorsoft/picky-color.在这里我打开一个关于它的一些问题的问题。问题:请建议我在Rails3应用程序中使用一些颜色选择器。 最佳答案 也许页面上的列表jQueryUIDevelopment:ColorPicker为您提供开箱即用的产品。原因是jQuery现在包含在Rails3应用程序中,因此使用基
查看我的Ruby代码:h=Hash.new([])h[0]=:word1h[1]=h[1]输出是:Hash={0=>:word1,1=>[:word2,:word3],2=>[:word2,:word3]}我希望有Hash={0=>:word1,1=>[:word2],2=>[:word3]}为什么要附加第二个哈希元素(数组)?如何将新数组元素附加到第三个哈希元素? 最佳答案 如果您提供单个值作为Hash.new的参数(例如Hash.new([]),完全相同的对象将用作每个缺失键的默认值。这就是您所拥有的,那是你不想要的。您可以改用