ViewPager多次调用transformPage()

时间:2016-06-20 09:31:41

标签: android android-viewpager

背景:

我使用public function add() { $data['HName'] = $this->input->post('HName'); $data['HDescription'] = $this->input->post('HDescription'); $data['Latitude'] = $this->input->post('Latitude'); $data['Longitude'] = $this->input->post('Longitude'); $data['CatagoryType'] = $this->input->post('CatagoryType'); $data['ParentID'] = $this->input->post('ParentID'); return $this->db->insert('hazara_tbl', $data); } public function getDisttforTehsil() { $query = $this->db->query('SELECT `HID`, `HName` FROM hazara_tbl WHERE `CatagoryType` = "District" '); return $query->result(); } 创建了无限轮播。此轮播在 <div class="form-group"> <label id="lblCatType">Catagory Type</label> <select class="form-control" name="CatagoryType" id="CatType"> <option value="None" selected="Selected">Select Catagory Type</option> <option value="District">District</option> <option value="Tehsil">Tehsil</option> <option value="Union Council">Union Council</option> <option value="Village">Village</option> <option value="Hotel">Hotel</option> <option value="Restaurant">Restaurant</option> <option value="Medical Store">Medical Store</option> <option value="Gov Dev Project">Gov Dev Project</option> </select> </div> <script> $(document).ready(function() { $("#lblDisttHotel, #disttHotel, #lblTehHotel, #tehHotel, #lblucHotel, #ucHotel, #lblVillageHotel, #villageHotel, #lblDisttNewUC, #disttNewUC, #tehNewUC, #lblTehNewUC, #lblDisttNew, #disttNew, #lblDistt, #distt, #lblTeh, #teh, #lblUC, #uc, #lblVillage, #village").hide(); $('#CatType').change(function() { if($(this).val() == 'Tehsil') // Tehsil selected { $("#lblDisttNew, #disttNew").show(); $("#lblDisttHotel, #disttHotel, #lblTehHotel, #tehHotel, #lblucHotel, #ucHotel, #lblVillageHotel, #villageHotel, #lblDisttNewUC, #disttNewUC, #tehNewUC, #lblTehNewUC, #lblDistt, #distt, #lblTeh, #teh, #lblUC, #uc, #lblVillage, #village").hide(); } else if ($(this).val() == 'Village') // Village selected { $("#lblDistt, #distt").show(); $("#lblDisttHotel, #disttHotel, #lblTehHotel, #tehHotel, #lblucHotel, #ucHotel, #lblVillageHotel, #villageHotel, #lblDisttNewUC, #disttNewUC, #tehNewUC, #lblTehNewUC, #lblDisttNew, #disttNew, #lblTeh, #teh, #lblUC, #uc, #lblVillage, #village").hide(); } }); $('#distt').change(function() { var myHID = $('#distt').val(); $.ajax( { url: 'http://localhost:83/ehazaratest/index.php/insert_data/getTehsilsForDistt', data: {id: myHID}, type: "post", success: function( msg ) { var aa = JSON.parse(msg); $("#teh, #lblTeh").show(); $('#teh').empty(); $.each(aa.query, function (key, value) { $("#teh").append($('<option></option>').val(value.HID).html(value.HName)); }) } }) }); // end of function $('#teh').change(function() { var myVHID = $('#teh').val(); $.ajax( { url: 'http://localhost:83/ehazaratest/index.php/insert_data/getUCForTehsils', data: {idV: myVHID}, type: "post", success: function( msg ) { var getData = JSON.parse(msg); $("#uc, #lblUC").show(); $('#uc').empty(); $.each(getData.Vquery, function (key, value) { $("#uc").append($('<option></option>').val(value.HID).html(value.HName)); }) } }) }); // end of function }); </script> <!-- Select District for Village --> <div class="form-group"> <label id="lblDistt">Select District for Village</label> <select class="form-control" id="distt" name="" > <?php foreach ($getDistt as $d ) { ?> <option value="<?php echo $d->HID; ?>"> <?php echo $d->HName;?> </option> <?php } ?> </select> </div> <!-- Select Tehsil for Village--> <div class="form-group"> <label id="lblTeh">Select Tehsil for Village</label> <select class="form-control" id="teh" name=""> <option value="None" selected="Selected">Select Tehsil</option> </select> </div> <!-- Select Union Council for Village --> <div class="form-group"> <label id="lblUC">Select Union Council for Village</label> <select class="form-control" name="ParentID" id="uc"> <option value="None" selected="Selected">Select Union Council</option> </select> </div> ViewPager模式下的显示方式不同。旋转木马旋转方向是从右到左。

在纵向模式下,“轮播”仅显示一张图像。见下图。此处,Landscape出现在屏幕上。黑色框架是屏幕显示区域。 其他图像不在屏幕显示中。

portrait mode

在横向模式下,Carousel将显示三张图像。见下图。这里, Portrait完全出现在屏幕上,而Image 3的某些部分出现在屏幕上。

landscape mode

现在,Image 3拥有自己的Image 2 and Image 4。在这里,我有覆盖ViewPager.PageTransformer函数。

对于ViewPager,offScreenPageLimit的默认值为transformPage(View view, float position)。我没有改变这个值。现在,在1模式下,在显示Image-3时,ViewPager将加载Image-2和Image-4。由于offScreenPageLimit值,它会调用Portrait函数 三次

问题:

问题出在ViewPager模式。在横向模式下,ViewPager将显示三个图像:transformPage()。由于offScreenPageLimit值,它将加载Image-1和Image-5。因此,理想情况下,它应该为{strong> 五次 调用Landscape函数。但是,它称之为 七次 。 WHY ??

我还观察到,调用Image-2, Image-3 and Image-4函数七次的顺序始终相同。

顺序:调用Image-3,Image-2,Image-1,Image-5(transformPage()),Image-4,Image-5,Image-1(transformPage()

为什么要调用CALL-ACALL-B?因为这个逻辑写在CALL-A中不能正常工作。

有人知道为什么会被称为 七次 ??

0 个答案:

没有答案