Posts

android - How to stop layout from taking all width -

Image
i have activity , need stop filling width of textview , button. these shown in centre filling width. how stop , make width fixed? please see layout below. <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="1280dp" android:layout_height="match_parent" android:gravity="center_vertical|center_horizontal" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".login" > <textview android:id="@+id/lblusername" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparent...

vb.net - randomising operators visual basic -

i want program (visual basic) randomly select times (*) or divide (/) , used operator in equation later in program. haven't started declaration of variables. thanks. you didn't provide code there can many solutions. have 2 operators, think best way go use conditions. basics use random class, , if or case . the code can this: function dosomeoperation(byval double, byval b double, optional byref op string = "") double dim rnd new random() select case rnd.next(0, 2) case 1 op = "/" return / b case else op = "*" return * b end select end function this code return operation result, , optionally operation used in op parameter. rnd.next(0, 2) statement returns either 0 or 1 (because maxvalue 2 , exclusive upper bound). *in real life should check result doesn't exceed double limits, , try..catch . example of function use in console app: dim d...

php - Most efficient way of getting first payment method used by all users -

lets have table in mssql database called "customers". have table called "orders", each of contains "customerid". want do, generate summary of payment method (let's call "paymentmethod") used first "order" of every "customer". the method have been using conduct customer selection query... select <columns> customers <where> ...and each result, conduct separate query obtain customer's first order's payment method: select top 1 paymentmethod orders order timestamp asc this process has benefit of obtaining data want in simple way that's easy modify, huge disadvantage of meaning query carried out every customer, mean tens-of-thousands of queries every single time! is there more efficient way of doing i'm not thinking of? i'm racking brain think of way of selecting directly "orders" table begin with, requirement query not group "customerid" fetch min() of ...

objective c - Not editable NSTextfiled, to make it auto resize when string is too long, like english word to French -

as question being posted, in textfield, when open app in english, works well, when switching french, know french word quite long , in case, words showing in textfield cut off. i tried customised way textfield on stack overflow, works editable textfield, when made none-editable, behaviour wired. it's when word long, make textfield longer, meaning increase width, not height. i'm expecting keeping width fix while changing height when word long. intrinsicsize = [super intrinsiccontentsize]; nstextview *textview = (nstextview *)fieldeditor; nsrect usedrect = [textview.textcontainer.layoutmanager usedrectfortextcontainer:textview.textcontainer]; kind of 2 main func used, when it's editable, went , height changes while width fix, when it's none editable, width changes. any advice? in nstextfield subclass override following methods. make sure nstextfield set wrap in ib. add constraints it. -(nssize)intrinsiccontentsize { // if wrap not e...

c++ - Including calib3d gives many compilation errors -

i trying use cv::rodrigues function in order rotation matrix given vector of angles. i have these includes in program: #include "opencv2/video/tracking.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/videoio/videoio.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/core.hpp" without adding #include "opencv2/calib3d.hpp" compiles fine. when add in order able use cv::rodrigues compilation fails many errors. i won't add whole error log because long , useless. starts this: <command-line>:0:9: error: expected identifier before numeric constant <command-line>:0:9: error: expected '}' before numeric constant <command-line>:0:9: error: expected unqualified-id before numeric constant and after have many error such : /usr/local/include/opencv2/features2d.hpp:1106:69: error: expected primary-expression before 'int' const s...

lisp - with hunchentoot I cannot generate web pages -

i learning common lisp , trying use hunchentoot develop web apps. with code below cannot manage see page defined in retro-games function definition on browser. expect generated function. i write address as: http://localhost:8080/retro-games.htm. what displayed on browser resource /retro-games.htm not found , message , lisp logo @ default page, display. can display hunchentoot's default page. (ql:quickload "hunchentoot") (ql:quickload "cl-who") (defpackage :retro-games (:use :cl :cl-who :hunchentoot)) (in-package :retro-games);i evaluate toplevel otherwise not change package. (start (make-instance 'hunchentoot:acceptor :port 8080)) (defun retro-games () (with-html-output (*standard-output* nil :prologue t) (:html (:body "not there")) (values))) (push (create-prefix-dispatcher "/retro-games.htm" 'retro-games) *dispatch-table*) the 2 loadings @ beginning successful. what missing? hunchento...

python - Syntax error on line containing if statement -

i keep trying make simple guess number game python keeps saying code has syntax error. doing wrong? import random takeone = input("guess number between 1 & 5") numberinit = random.randint(1,5) if "takeone" == "numberinit" print("your right") else: print("your wrong") the syntax error you're getting following: file "test.py", line 4 if "takeone" == "numberinit" ^ syntaxerror: invalid syntax this means you're missing colon @ end of if line. line should instead read: if "takeone" == "numberinit":