cursor

How to find a pixel-positon of a cursor in UITextView?

自古美人都是妖i 提交于 2019-11-30 09:51:30
I'm developing a simple writing app for iPad. I'm trying to compute the pixel-position of the cursor in UITextView . I spend a few weeks to design this, but I still couldn't figure out to do it. In stackoverflow, Tony wrote one good algorithm to find the pixel-position of the cursor. Pixel-Position of Cursor in UITextView I implemented this with a little modification, and it almost works that it gives the correct pixel-position of the cursor. However, it only works with English alphabets. If there is Chinese or Japanese character at the end of line, UITextView performs character-wrapping,

Android SQLite Query Where and Where

北城以北 提交于 2019-11-30 09:44:14
问题 I need to return the ID value from the database where dan == table_column_one and where vrijeme == table_column_two. I don't know how to do this. public static int returnID(String dan, int vrijeme){ Cursor cursor; int IDRQ; cursor = db.query ( TABLE_NAME, new String[] { TABLE_COLUMN_ID, TABLE_COLUMN_ONE, TABLE_COLUMN_TWO }, new String[] {TABLE_COLUMN_ONE + " like " + "'%" + dan + "%'", TABLE_COLUMN_TWO + " like " + "'%" + vrijeme + "%'"}, null, null, null, null ); cursor.moveToFirst(); IDRQ =

MySQL-python connection does not see changes to database made on another connection even after change is committed

匆匆过客 提交于 2019-11-30 08:27:21
I am using the MySQLdb module for Python (v1.2.3 precompiled binary for Windows Python 2.7) to read and write data to a MySQL database. Once a connection is open, I can use that connection to observe changes made to the database on that same connection, but do not see changes made using another connection, regardless of whether the other connection is made in Python or there is a change made using the MySQL command line client. In the case where I am making updates using Python, note that I am running the commit() command on the connection. Example of program that inserts new records into a

css cursor using data-uri

江枫思渺然 提交于 2019-11-30 08:26:41
问题 I'm trying to use custom png cursor using data uri but the cursor doesn't change. I've tested on FF 17 which support png as custom cursor. The same data uri work as a background image. Am I using wrong syntax or maybe data-uri can't be used as a cursor image? example: http://jsfiddle.net/u8t3j/ <!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>cursor test</title> <style> #cursor { width: 300px; height: 300px; border: 1px solid black; cursor: url(data:image/png;base64

How to (properly) transition from startManagingCursor to CursorLoader?

ε祈祈猫儿з 提交于 2019-11-30 08:25:40
I updated my android SDK to the latest version, and now it says that startManagingCursor() is deprecated . I need help to update my code to use the new CursorLoader . private void fillData() { Cursor notesCursor = mDbHelper.fetchAllNotes(); startManagingCursor(notesCursor); NoteAdapter notes = new NoteAdapter(this, R.layout.notes_row, notesCursor); setListAdapter(notes); } So, startManagingCursor() is old, what would the new code look like, if it was translated? First, startManagingCursor() still works. It is not ideal, in that it performs database I/O on the main application thread. In

Out of Memory when allocating cursors

落爺英雄遲暮 提交于 2019-11-30 08:24:17
I have a memory problem that I can't figure out. I have one class that does all my database retrieving work. The error I have is the following: android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=733 (# cursors opened by this proc=733) The memory allocation error occurs when I do this: mDatabaseInterface.getGraphForLevel(level); I know it's a leak because I call this method every 2.5 seconds roughly, and the 5 or 6 first calls go through easily. Now here are the methods in my DatabaseInterface class: public Graph getGraphForLevel(Level

Necessity of explicit cursor.close()

こ雲淡風輕ζ 提交于 2019-11-30 08:08:43
From time to time, I'm executing raw queries using connection.cursor() instead of using ORM (since it is definitely not a silver bullet). I've noticed that in several places I don't call explicit cursor.close() after I'm done with database. So far, this hasn't result into any errors, or performance issues. I'm wondering what kind of problems could I possibly have without closing the cursor explicitly, what can go wrong? As far as I understand, connection and cursor in Django follow "Python Database API Specification v2.0" ( PEP-249 ). And, according to it, cursor would be automatically closed

Which is faster in SQL, While loop, Recursive Stored proc, or Cursor?

不羁的心 提交于 2019-11-30 07:49:53
问题 Which is faster in SQL, While loop, Recursive Stored proc, or Cursor? I want to optimize the performance in a couple of spots in a stored procedure. The code I'm optimizing formats some strings for output to a file. 回答1: I'll assume you are using SQL Server. First of all, as someone said in the statements, recursive stored procs, while possible, are not a good idea in SQL Server because of the stack size. So, any deeply recursive logic will break. However, if you have 2-3 levels of nesting at

INSERT and UPDATE a record using cursors in oracle

亡梦爱人 提交于 2019-11-30 07:45:21
I have 2 tables- student and studLoad both having 2 fields studID and studName . I want to load data from student table into stuLoad table. If the data already exists in the studLoad table, then it should be updated else it should be inserted. following is my code to do so: create or replace procedure studentLoad is v_id student.studID%type; v_name student.studName%type; v_sn studLoad.studName%type; cursor cur_load is select * from student; begin open cur_load; loop fetch cur_load into v_id,v_name; exit when cur_load%notfound; select studName into v_sn from studLoad where studID = v_id; if(v

How to access the structure and get the column list ,datatypes of refcursor?

こ雲淡風輕ζ 提交于 2019-11-30 07:39:38
问题 I have a procedure which gets me the output with refcursor and data/structure in cursor will be dynami. Each time depending on inputs datatypes and no of columns in cursor will vary. So how can I access this structure and get the datatypes ? PROCEDURE PROC_B ( name_ IN VARCHAR2, date_ IN DATE, code_ IN VARCHAR2, sp_name_ IN VARCHAR2, wrapper_ OUT sys_refcursor, datyapes_ OUT VARCHAR2, TS2_ OUT VARCHAR2, header_ OUT VARCHAR2) AS TS_ DATE; BEGIN PROC_A (name_, date_, code_, sp_name_, wrapper_,