如何知道Android ActionBar选项卡式活动中哪个选项卡在视图中(How to know which tab is in view in an Android ActionBar Tabbed Activity)
所以我使用ViewPager使用ActionBar Tabbed Activity创建了一个Android应用程序项目。 我还创建了两个片段类,并附加了相应的片段布局。 在选择相应的选项卡时,我将片段返回到SectionsPagerAdapter。
public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). switch (position) { case 0: return new fragmentAddSize(); case 1: return new fragmentMySizes(); } return null; } }
现在我对此有一些疑问。 我的印象是,每次选择一个选项卡时,它都会调用片段类并进入片段的onCreateView,但它只发生一次。
我想要实现的是知道何时选择选项卡并且相应的片段在视图中。 因此,每当我切换标签时,它只会弹出标签1或标签2中的标签符号。
So I created an Android application project using ActionBar Tabbed Activity using ViewPager. I've also created two fragment classes and attached corresponding fragment layout with them. As the respective tab is selected I return fragment to SectionsPagerAdapter.
public class SectionsPagerAdapter extends FragmentPagerAdapter { public SectionsPagerAdapter(FragmentManager fm) { super(fm); } @Override public Fragment getItem(int position) { // getItem is called to instantiate the fragment for the given page. // Return a PlaceholderFragment (defined as a static inner class below). switch (position) { case 0: return new fragmentAddSize(); case 1: return new fragmentMySizes(); } return null; } }
Now I have some questions about this. I was under the impression that every time a tab is selected, it calls the fragment class and goes into the onCreateView of the fragment but it only happens once.
What I want to achieve is to know when the tabs are selected and the corresponding fragment is in view. So that everytime i switch tabs it just pops a tab sying you are in tab 1 or tab2.
原文:https://stackoverflow.com/questions/26657971
最满意答案
这种程序集中的CMP通常会将一个值与参数进行比较,并设置一个标志/如果匹配。 然后,如果设置了该标志,JEQ将跳转。
如果你告诉我你的目标处理器是什么,我可以更加精确,甚至使用正确的术语,等等=)
CMP in that sort of assembly will generally compare a value to the argument, /and set a flag/ if it matches. Then JEQ will jump if that flag is set.
If you told me what your target processor is, I could be a lot more precise about it, and even use correct terminology, etc. =)
相关问答
更多-
在foldr中的累加器(Accumulator in foldr)[2021-11-15]
考虑根据您提供的(正确)定义评估简单的foldr表达式: foldr (+) 0 [1,2,3,4] = 1 + foldr (+) 0 [2,3,4] = 1 + 2 + foldr (+) 0 [3,4] = 1 + 2 + 3 + foldr (+) 0 [4] = 1 + 2 + 3 + 4 + foldr (+) 0 [] = 1 + 2 + 3 + 4 + 0 = 10 所以你是对的: acc并不真正“积累”任何东西。 它永远不会取0以外的0 。 如果它不是累加器,它为什么叫做“acc”? ... -
START: LDA #$11 ; load accumulator - A=$11 STA $2123 ; store accumulator to a memory address - memory[$2123] = $11 CLRA - A=$00 (redundant, as next instruction will load A again) LDA #$67 ; load accumulator - A=$67 ...
-
基本累加器程序(Basic accumulator program)[2022-04-04]
这种程序集中的CMP通常会将一个值与参数进行比较,并设置一个标志/如果匹配。 然后,如果设置了该标志,JEQ将跳转。 如果你告诉我你的目标处理器是什么,我可以更加精确,甚至使用正确的术语,等等=) CMP in that sort of assembly will generally compare a value to the argument, /and set a flag/ if it matches. Then JEQ will jump if that flag is set. If you t ... -
可重置的累加器行为?(Resettable accumulator behaviors?)[2022-02-24]
这个想法是eToPrint是两个事件的结合:当你按下字符时和按下回车键。 这里有一个例子(反应性香蕉0.8): eToPrint = accumE "" $ unions [(:) <$> eWritable, const "" <$> eEnter] 要“保持”它,您可以使用Behavior 。 这是一个完整的解决方案: bString = accumB "" $ unions [(:) <$> eWritable, const "" <$> eEnter] eOut = bString <@ e ... -
如何将累加器值与装配中的特定正整数进行比较?(How do I compare accumulator value to specific positive integer in assembly?)[2023-10-10]
注意 a≤2⇒a - 2≤0⇒a - 2 <0∨a= 0 可以使用现有说明测试这两种情况。 如果你想实现if (a0 <= a1) ... else ...你可以使用 LODD a0 /Accumulator = a0 SUBD a1 /Accumulator = a0 - a1 jzer _THEN_branch /Jump to "then branch" if a0 == a1 jneg _THEN_branch /Jump to "th ... -
使用累加器映射到对象(Map to object with an accumulator)[2023-07-25]
这就是.reduce()的用途: var accumulator = _.reduce([1, 2, 3], function(acc, num) { acc[num] = num + 1; return acc; }, {}); 在现代浏览器中,Array原型上的原生.reduce()与lodash和Underscore提供的版本大致相同。 .map() API用于从现有数组创建新数组。 如果你只想对数组的每个元素做一些事情,你可以使用.forEach() 。 .filter() API用于创建数 ... -
什么是不使用join的动机? lst = [52.0, 55.0, 567.0, 92.0, 2.0, 5.0] def foo(lst): bar = '' for i in lst: i = format(i, '.2f') bar+= '${}, '.format(str(i)) bar = bar.rstrip(', ') return '{'+bar+'}' print(foo(lst)) Whats the motiviati ...
-
我添加了一个新的答案,因为我已经修复了这个问题,我刚刚上传到Hackage的pipes-3.3 -3.3。 管道背后的理论表明,您期望的全局行为一直是正确的行为,而WriterP现在表现为全局,因此您可以在管道中折叠。 我修改了你的例子,表明你将使用pipes-3.3实现它pipes-3.3 : import Control.Proxy import Control.Proxy.Trans.Writer main = do let source = enumFromToS (0::Int) 5 ...
-
CPU必须有累加器吗?(Must CPU have an accumulator?)[2022-05-25]
是的,您不需要CPU的累加器。 例如,基于堆栈的处理器通常只有一个或两个堆栈指针但没有累加器。 正如文章所说,这些处理器在操作之前加载值以便从内存进行操作。 Yes, you don't need an accumulator for a CPU. For example, stack-based processors typically only have one or two stack pointers but no accumulator. As the article says, these pr ... -
elixir如何保持累加器(How elixir keep the accumulator)[2022-06-04]
不知道你错过了什么/问什么,但让我试一试。 首先,您必须知道流如何工作并在Elixir中表示:流只是一组在可枚举上运行的函数。 当你组成流(例如, 1..3 |> Stream.map(...) |> Stream.map(...) )时,你没有1..3 |> Stream.map(...) |> Stream.map(...)做任何“具体”,你只是将函数添加到将用于处理初始可枚举的函数列表中。 当用流调用Enum.reduce/3时,就是当你开始迭代可枚举时(一次一个元素)。 通过检查Enum.reduc ...