Posts

TextView improperly displaying in Layout in Android 6 and below -

Image
i dynamically creating views in oncreate() , use setmargins() , setlayoutparams() position them on layout. this works expected in android 7 parameters ignored in android 6 , below. i assume has views not being created in oncreate() or dont know why work in android 7, or how around it. below example code of problem , screenshots visualization. @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); viewgroup viewgroup = (viewgroup) findviewbyid(android.r.id.content); relativelayout.layoutparams viewparam = new relativelayout.layoutparams( relativelayout.layoutparams.wrap_content, relativelayout.layoutparams.wrap_content); viewparam.setmargins(200, 400, 0, 0); textview mytextview = new textview(this); mytextview.settext("hello text"); mytextview.settextsize( typedvalue.complex_unit_px, 50); mytextview.setgr...

swift3 - cs193p cassini unable to show images -

working on xcode 8.3.3, using swift 3. following paul's cs193 course stanford on youtube. have not been able load images. zero. have hardcoded test image (and print shows present), it's not enough simulator. question: missing or needs change? first image second image

html - Bootstrap Squared Columns for Tic-Tac-Toe Board? -

i building tic-tac-toe interface, using html, css, , bootstrap. i'm trying board squared (1:1) i'm getting nowhere. the boxes have taller use more space. can playing height property using vw / vh units on columns, won't keep 1:1 ratio across resolutions. tic tac toe this other version has "pads" on each side of board , job breaks on sizes smaller tablets. apart lose space. tic tac toe pads now, here's code tic tac toe without pads: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>tic tac toe</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/y6pd6fv/vv2hjna6t+vslu6fwyxjcftcephbnj0lyafsxtsjbbfadjzaleqsn6m" crossorigin="anonymous"> ...

uigesturerecognizer - Swift invert UIRotationGestureRecognizer for subviews -

i want invert rotation uirotationgesturerecognizer specific subviews. rotation occurs in 90 degree phases (so cgfloat.pi / 2 ) func localhandlerotategesture (localrotategesture: uirotationgesturerecognizer) { if localrotategesture.state == .ended { if localrotategesture.rotation > 0.0005{ localrotategesture.view?.transform = (localrotategesture.view?.transform)!.rotated(by: cgfloat.pi / 2) } localrotategesture.rotation = 0 } works fine. access subviews , try invert movement var thiscell = localrotategesture.view as! custommessagecell thiscell.cellbuttonsstackview.transform = (localrotategesture.view?.transform.inverted())!.rotated(by: cgfloat.pi / 2) the subviews rotate first attempt, , after doesn't! going on?

Javascript / Ajax: assigning value to a new object and deleting one of the element -

i'm making ajax request , assigning dataset of request new object {} using object.assign() method , subsequently wants delete 1 of item in new object. when console.log() original dataset, value deleted there aswell. why when i'm assigning using object.assign() method? how can stop js that? $.ajax({ url: "{% url 'filtered_financial' %}", method: 'get', data : { airline_category: 1, }, success: function(dataset){ var datacopy = object.assign({}, dataset); delete datacopy.financial_year console.log(dataset) // financial_year element deleted )};

web scraping - Using python scrapy to extract link and text -

i new python , scrapy. extract information website http://www.vodafone.com.au/about/legal/critical-information-summary/plans including link document, name , valid to. i tried code, not work. appreciated if explain , me. here file vodafone.py import scrapy scrapy.linkextractor import linkextractor scrapy.spiders import rule, crawlspider vodafone_scraper.items import vodafonescraperitem class vodafonespider(scrapy.spider): name = 'vodafone' allowed_domains = ['vodafone.com.au'] start_urls = ['http://www.vodafone.com.au/about/legal/critical-information-summary/plans'] def parse(self, response): sel in response.xpath('//tbody/tr/td[1]/a'): item = vodafonescraperitem() item['link'] = sel.xpath('href').extract() item['name'] = sel.xpath('text()').extract_first() yield item it doesn't work because page content generated dynamicall...

php - Faster counting and sum data faster in for loop -

i'm working on counting students' data database contains thousands of rows , have within loop, problem calculation slow. what's best way make faster? query command: $sql_query = $con->prepare("select id_number,title,name,lastname,classroom students academic='".$config['info']['year']."' order id_number"); $sql_query->execute(); while($fetchar = $sql_query->fetch(pdo::fetch_obj)){ $ss_data[] = $fetchar->id_number.'-'.$fetchar->title.$fetchar->name.'&nbsp;'.$fetchar->lastname.'-'.$fetchar->classroom; } $row_counts = count($ss_data); for($i=0;$i<$row_counts;$i++){ $e = explode("-",$ss_data[$i]); $id = $e[0]; //รหัสประจำตัวนักเรียน $personal_data = $e[1]; //ข้อมูลนักเรียน $room = $e[2]; //ระดับชั้น //คิวรี่จำนวนการร่วมกิจกรรมของนักเรียนแต่ละคน ทั้งโรงเรียน $sql = $con->prepare("select count(std_id) present_count attendance std_...