Posts

java - Passing Custom Binder between packages -

how send custom binder object between android packages? service activity (in separate packages)? i've been playing while cannot seem work. custombinder contained in library both packages have copy of. the error @ casting point in onserviceconnected. see "casting failed". i've noticed bit more interesting things this. when override tostring method in custombinder, , make return string, , print out binder get, "android.os.binderproxy" instead. updated code reflect: package 1 (contains activity) private serviceconnection mconnection = new serviceconnection(){ @override public void onserviceconnected(componentname name, ibinder binder){ log.d("tag",binder.tostring()); try{ custombinder nbinder = (custombinder)binder; log.d("tag","it worked!"); }catch(exception e){ log.d("tag","casting failed again"); }...

c - Why does this code yield a segmentation fault? -

i writing program goal generate random 3 digit number, , have user make 10 guesses @ it. if guess correct digit in correct spot, considered "hit". if guess correct digit it's in wrong spot, considered "match". example, if number guessed 123, , enter 329, 2 hit , 3 match. code far shown below: #include <stdio.h> #include <time.h> #define min 100 #define max 999 int main() { //declare variables int userdig1 = 0, userdig2 = 0, userdig3 = 0, randdig1 = 0, randdig2 = 0, randdig3 = 0, guesses = 0; //generate random 3 digit number srand(time(null)); //seed randdig1 = rand() % ((max + 1) - min) + min; //corresponds first digit randdig2 = rand() % ((max + 1) - min) + min; //corresponds second digit randdig3 = rand() % ((max+ 1 ) - min) + min; //corresponds third digit //a loop keeps track of number of guesses (guesses = 1 ; guesses <= 10 ; guesses++) { //store user's guess appropriate variables ...

java - How to bind SQLite data to textview in Android -

i'm looking simplest way bind value in sqlite column textview. have hundred textviews across number of activities. i have dbhelper class define table , columns , sqlcontroller class define methods insert, , update data. of pretty boilerplate code. for each activity open database, set cursor , data, update database when activity closes. is there library can use bind fields in db textview directly? use butterknife bind data objects views , considering implementing android data binding, wondering if there's way go directly database view without having write boilerplate code?

increment - Incrementing +1 through range -

i trying randomise set of increments on large number of variables. so example, have 5,000 people, each of these people has base value of 1, adding 1 has variable affect each of these people. example adding 1 person a, means there base number increments 1.1. adding 1 person b increments base 1.4 , on. i have figured out how different values assigned each +1 action vlookups, need loop +1 increments through range. i have base values setup in column b:b can't figure out how loop script. have far: function increment(){ var ss = spreadsheetapp.getactivespreadsheet(); var sheet = ss.getsheets()[1]; var range = sheet.getrange("b1"); var value = range.getvalue(); for (var = 1; >= range; i++); range.setvalue(value + 1); } but increments 1 "b1". how loop runs continously, every second through b1, b2, b3, b4 etc adding +1 each time? simply adding range name using "b" + in getrange() function, , move loop. or can use offse...

javascript - How to create a dropdown menu without messing up the rest of the code....? -

i know question has been asked before million times, can't seem find answer or solution fits exact situation or code. (if there one, please link me!) i'm trying create simple dropdown menu on horizontal navigation has logo image centered links on either side. have bootstrap installed, can't seem figure out simple way code using framework, said screw , built 1 scratch. it doesn't have straight html/css, i'm not super familiar js (still learning). here's current code: #header { height: 40px; position: relative; margin: 80px auto 0; } #header ul { margin: 0 auto; width: 800px; padding: 0; list-style: none; } #header ul li { float: left; width: 97px; } #header ul li:nth-of-type(4) { margin-left: 217px; } #header ul li { text-transform: lowercase; text-decoration: none; display: block; text-align: center; padding: 12px 0 0 0; height: 28px; color: #000;...

What is "Memory Management" in iOS? -

i have been given these 2 questions in interview. 1. **memory management** in ios. 2. reference counting? can 1 explain me? new ios. please me out. in advance! application memory management process of allocating memory during program’s runtime, using it, , freeing when done it. well-written program uses little memory possible. in objective-c, can seen way of distributing ownership of limited memory resources among many pieces of data , code. when have finished working through guide, have knowledge need manage application’s memory explicitly managing life cycle of objects , freeing them when no longer needed. reference counting

algorithm - How to code a dynamic solution for the 0/1 Knapsack with a specific number of each item -

is possible code dynamic solution 1/0 knapsack problem has requirement number of each item? for example knapsack requires: 1 of item_one 2 of item_two 3 of item_three 1 of item_four 1 of item_five 1 of item_six each item has weight , there max weight of 60000 in sense normal knapsack problem. beyond difference im trying minimize value instead of maximize. here brute force code in vba im running on hunderes of items need faster solution. help! function knapsacksolver(item_one, item_two, item_three, item_four, item_five, item_six) dim knapsack variant redim knapsack(1 9, 1 5) variant dim value long dim minvalue long dim cap long dim weight long minvalue = 9999999 weight = 0 cap = 60000 = 1 ubound(item_one) j = 1 ubound(item_two) t = 1 ubound(item_two) if j <> t m = 1 ubound(item_three) n = 1 ubound(item_three) ...