Posts

Android - getSupportFragmentManager returns null -

i trying specific instance of fragment using it's tag, using viewpager, makes things difficult. used: public fragment getfragmentbyposition(int pos) { string tag = "android:switcher:" + r.id.pager + ":" + pos; fragmentmanager fragmentmanager = this.getsupportfragmentmanager(); fragment fragment = fragmentmanager.findfragmentbytag(tag); return fragment; } to find fragment, getsupportfragmentmanager returning null. the above method in activity, outside of viewpager adapter class, , lost here. highly appreciated, thanks! you can use smartviewpager here https://gist.github.com/jacek-marchwicki/d6320ba9a910c514424d extend view pager class , fragment using getactivefragment method. can change implementation of method fragment tag name. public fragment getactivefragment(string name) { final fragment fragmentbytag = fragmentmanager.findfragmentbytag(name); if (fragmentbytag == null) { final bytearrayoutputstream out...

Doubts about top level class acess modifiers in Java -

i have doubts access modifiers used top level classes in java. 1) can access modifier public or default used top level classes or nested classes? 2) lets there 2 different classes , b, both in different packages. in order have access (acess class members) class class b , both top level class, ‘a’ class members should defined public, right ? if either class or class members not public class b not have access class a, right ? please correct if i'm wrong. 1) nested classes can have same access modifiers top level classes. 2) in order access class class b, needs public. class b may package private (default). b can access methods of if a's methods public (if b not inherit a). if class package private, doesn't matter if contains public methods - won't accessible b. see oracle docs , this stackoverflow thread .

android - How to generate multiple buttons that have the same intent but have another Extra -

im trying generate multiple views in eclipse layoutinflater. button has onclicklistener , works. intent starts , give extra. but want button keeps own extras. saying first button has extra: number 1 second has 2 , on. @ moment al buttons same extra, number 5. because when try intent in com.example.http wizard says 5 string[] title = { "1", "2", "3", "4", "5" }; layoutinflater layoutinflator = (layoutinflater) getapplicationcontext().getsystemservice(context.layout_inflater_service); linearlayout insertpoint = (linearlayout) findviewbyid(r.id.ll_content); list<view> views = new arraylist<view>(); for(int i=0; i<title.length; i++){ view view = layoutinflator.inflate(r.layout.single_task, null); textview textview = (textview) view.findviewbyid(r.id.tvname); button bstartwizard = (button) view.findviewbyid(r.id.bstartwizard); textview.settext("opdrac...

c++ - SDL_mixer wont play sound Raspberry Pi -

i can't sdl_mixer play sound on raspberry. program compiles , builds ok, hear short squeak (like static) , nothing. any ideas? #include <sdl/sdl.h> #include <sdl/sdl_mixer.h> #include <stdio.h> #include <string> #include <iostream> int main() { mix_chunk *snd1 = null; mix_music *m = null; if(sdl_init(sdl_init_video | sdl_init_audio) < 0) { std::cout << "something went wrong"; } if(mix_openaudio(44100, mix_default_format, 2, 1024) < 0) { std::cout << "kunne ikke loade musikk"; } snd1 = mix_loadwav("bicycle_bell.wav"); if(snd1 == null) { std::cout << "fant ikke filen"; } mix_playchannel(-1, snd1, 0); mix_freechunk(snd1); mix_quit(); return 1; } solved it. program terminated before sound playing. when testing simple: while(mix_playing(sound)); fixed it.

c++ - menu callback in not called -

i want add couple of buttons - "settings" , "restart" scene, placed above everything. below [in init()]: auto settingsmenu = menuitemimage::create("settings_gold@2x.png", "settings_white@2x.png", cc_callback_1(gamelevellayer::settingsbuttontapped, this)); settingsmenu->setposition(point(440, 280)); this->addchild(settingsmenu); i add touch handler process game "actions," below: // handle user touches auto dispatcher = director::getinstance()->geteventdispatcher(); auto listener = eventlistenertouchonebyone::create(); listener->ontouchbegan = cc_callback_2(gamelevellayer::ontouchbegan, this); listener->ontouchended = cc_callback_2(gamelevellayer::ontouchended, this); dispatcher->addeventlistenerwithscenegraphpriority(listener, this); my ontouchbegan() , ontouchended() called fine, settingsbuttontapped() never called, touch handler apparently swallows everything. how should processed in cocos2d-x 3.x, click...

javascript - How can I select using jQuery 'select' tag with determined selected option? -

for instance, <div id="wrapper"> <select> <option value="en" selected="selected">english</option> <option value="ar">العربية</option> <option value="az">azərbaycanlı</option> <option value="bg">български</option> <option value="ca">català</option> <option value="cs">český</option> <!-- data cut --> </select> <select> <option value="en" >english</option> <option value="ar">العربية</option> <option value="az" selected="selected">azərbaycanlı</option> <option value="bg">български</option> <option value="ca">català</option> <option value="cs">český</option...

Unable to connect mysql via django -

i know old question on lots of forums answers suggesting flush privileges , reset passwords in case no answer has worked. here's scenario: i able connect mysql via following command mysql -u root -p -hlocalhost i able connect via python using following script import mysqldb con = mysqldb.connect(host="127.0.0.1", port=3306, user="root", passwd="mypass", db="mydb") cursor = con.cursor() sql = "select * test" cursor.execute(sql) #### gives 1l but unable connect via django. django settings.py contains databases = { 'default': { 'engine': 'django.db.backends.mysql', 'name': 'mydb', 'user': 'root', 'passwd': 'mypass', 'host': 'localhost', 'port': '3306', } } following main error django.db.utils.operationalerror: (1045, "access denied user 'root...