是否有任何生命周期方法在每次打开片段时都会被调用?

时间:2018-08-25 10:14:22

标签: java android android-fragments android-viewpager

我尝试使用ViewPager,但是在某些情况下,它不会与Sub Macro1() Start = 2 'Change path to your excel's file name 'This will open your 2nd excel file so that you won't have to open it evertime. Delete when not needed Workbooks.Open ("C:\Users\Pops\Desktop\Excel2.xlsm") 'The deletion of the row will mess up with the For-Next loops so I included a GoTo so this is where it will end up ReLoop: 'Counts how many rows are in your worksheets Total_rows_Excel1 = Workbooks("Excel1.xlsm").Worksheets("Sheet1").Range("C" & Rows.Count).End(xlUp).Row Total_rows_Excel2 = Workbooks("Excel2.xlsm").Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row 'Loops on all the rows on your worksheet For i = Start To Total_rows_Excel1 For j = 2 To Total_rows_Excel2 If Workbooks("Excel1.xlsm").Worksheets("Sheet1").Range("C" & i) = Workbooks("Excel2").Worksheets("Sheet1").Range("A" & j) Then Workbooks("Excel1").Worksheets("Sheet1").Rows(i).Delete Shift:=xlUp 'Deletes the rows in Excel1 that have a match from Excel2 Start = i 'This will let the loop to start at the last row it stopped when it loops again so it's less computationally taxing GoTo ReLoop End If Next j Next i End Sub 一起调用,尤其是当要从tablayout上最近的tab片段化时。

有什么问题吗?

还有其他显式调用的事件吗?

1 个答案:

答案 0 :(得分:0)

当片段对用户可见并正在运行时,将调用

Fragment#onResume()。通常,这与包含Activity生命周期的Activity.onResume相关。