Daily Archives

Articles indexed Thursday February 17 2011

Page 7/12 | < Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How to embed evince in firefox 4?

    - by Alaukik
    I installed mozplugger and created the file mozpluggerrc with the following content according to this post But whenever I open a .pdf it opens in a separate evince windows is there a way I can truly embed it in Firefox like the chrome pdf reader? application/pdf: pdf: PDF file application/x-pdf: pdf: PDF file text/pdf: pdf: PDF file text/x-pdf: pdf: PDF file application/x-postscript: ps: PostScript file application/postscript: ps: PostScript file application/x-dvi: dvi: DVI file : evince $file

    Read the article

  • Enforce VPN connection to access the Internet

    - by ch0wn
    I'm using a VPN when I'm online at an unencrypted wifi. Unfortunately, at my university the connection is quite unstable and at every reconnect the VPN connection is terminated and I manually need to reconnect to it using the NetworkManager, which obviously only works if I notice the reconnect. I enabled the option to automatically connect to the VPN in the NM options, but it seems to have no effect. Is there a way to enforce an active VPN connection before any other application can access the network connection so I can be sure not to send private data over unencrypted connections? Cheers, Pascal

    Read the article

  • Sound Problem due to wrong driver installation

    - by Starx
    First of all, the audio used to play from the speaker but whenever I connected a headphone or speaker in the I, the sound didn't came. So I installed a realtek sound driver to fix this (actually I didn't find any relevant driver for my sound card so I installed it hoping it would show some light) When I rebooted the system, my sound is completely gone and now ubuntu does not detect any sound devices in my system. I clearly installed wrong driver, now I need to remove and go to previous stage and find a correct driver. My laptop is: Dell Studio 1747, uses a speaker Creative Labs Sound X-Fi MB Sound Blaster and the chipset is INTEL PM55. How can I fix this?

    Read the article

  • Decrease mouse sensitivity below the standard limit.

    - by Bruce Connor
    I've got a USB mouse attached to my Ubuntu notebook. This mouse is (unfortunately) really sensitive, and so it sometimes gets hard to hit small icons with the mouse pointer. This is really a hardware issue, it's not a bug and it's not Ubuntu's/gnome's fault. Still, I would very much like to this issue through software (solving through hardware would imply buying a new mouse). Back in Windows, if I set the sensitivity as really low it was comfortable enough. In Ubuntu, even the lowest sensitivity and acceleration available (in the SystemPrerencesMouse menu) is still frustrating. How can I decrease it below the default minimum? I tried xset, but it seems xset only deals with acceleration and threshold, but not actual sensitivity.

    Read the article

  • DNS hijack - prevention tips

    - by user578359
    Hi there, Over the weekend it looks like the DNS was hijacked on two of my domains. My set up is I have the sites registered on 1and1.co.uk, with dns nameservers pointing to Hostgator in the US where the sites are hosted. I also had cloudflare CDN running on the sites (via hostgator cpanel). My question is any ideas as to how this happened, and how I could either monitor it so I know if it occurs again, or strengthen the set up/service to minimise the risk. History: I received a ping from my site monitoring service that the sites were down. When I checked the sites were up so I assumed it was local to the monitoring service I received a ping last night the sites were up When I checked, one site was redirecting to download-manual.com (and checking that URL now, the home page is not the same as the one I saw, so they too may have been hijacked/hacked) The other site URL remained the same but had one of those standard site search pages which bounce you off to either phishing or paid for search sites I notified Hostgator who told me Cloudflare or 1and1 were the issue. I removed cloudflare, and contacted both them and hostgator, and am awaiting a response, but am not holding my breath. Is this common? I've never heard of this or come across this before. It's pretty scary that this can happen so easily. Appreciate any input. **Update: I've now spoken to support at 1and1, Hostgator, and Cloudflare, and each one claims it has nothing to do with them, and must be one of the others. Larry, curly, moe.

    Read the article

  • List of freely available SEO tools (software) for keyword rank checking? [closed]

    - by Craig
    Possible Duplicate: can anyone reccommend a Google SERP tracker? Requirements: Analysis of site positions on the list of keywords in different search engines; Track keyword positions on search engines. I want see if my keyword rankings have moved up or down; Creating reports. I use Excel + Rank Checker addon for Firefox, to analyze the position of the site in search engines for my keyword list. Are there any tools which tested and working properly. Thanks.

    Read the article

  • Drawing large 2D sidescroller level terrain

    - by Yar
    I'm a relatively good programmer but now that it comes to add some basic levels to my 2D game I'm kinda stuck. What I want to do: An acceptable, large (8000 * 1000 pixels) "green hills" test level for my game. What is the best way for me to do this? It doesn't have to look great, it just shouldn't look like it was made in MS paint with the line and paint bucket tool. Basically it should just mud with grass on top of it, shaped in some form of hills. But how should I draw it, I can't just take out the pencil tool and start drawing it pixel per pixel, can I?

    Read the article

  • Seperation of drawing and logic in games

    - by BFree
    I'm a developer that's just now starting to mess around with game development. I'm a .Net guy, so I've messed with XNA and am now playing around with Cocos2d for the iPhone. My question really is more general though. Let's say I'm building a simple Pong game. I'd have a Ball class and a Paddle class. Coming from the business world development, my first instinct is to not have any drawing or input handling code in either of these classes. //pseudo code class Ball { Vector2D position; Vector2D velocity; Color color; void Move(){} } Nothing in the ball class handles input, or deals with drawing. I'd then have another class, my Game class, or my Scene.m (in Cocos2D) which would new up the Ball, and during the game loop, it would manipulate the ball as needed. The thing is though, in many tutorials for both XNA and Cocos2D, I see a pattern like this: //pseudo code class Ball : SomeUpdatableComponent { Vector2D position; Vector2D velocity; Color color; void Update(){} void Draw(){} void HandleInput(){} } My question is, is this right? Is this the pattern that people use in game development? It somehow goes against everything I'm used to, to have my Ball class do everything. Furthermore, in this second example, where my Ball knows how to move around, how would I handle collision detection with the Paddle? Would the Ball need to have knowledge of the Paddle? In my first example, the Game class would have references to both the Ball and the Paddle, and then ship both of those off to some CollisionDetection manager or something, but how do I deal with the complexity of various components, if each individual component does everything themselves? (I hope I'm making sense.....)

    Read the article

  • Logging library for (c++) games

    - by Klaim
    I know a lot of logging libraries but didn't test a lot of them. (GoogleLog, Pantheios, the coming boost::log library...) In games, especially in remote multiplayer and multithreaded games, logging is vital to debugging, even if you remove all logs in the end. Let's say I'm making a PC game (not console) that needs logs (multiplayer and multithreaded and/or multiprocess) and I have good reasons for looking for a library for logging (like, I don't have time or I'm not confident in my ability to write one correctly for my case). Assuming that I need : performance ease of use (allow streaming or formating or something like that) reliable (don't leak or crash!) cross-platform (at least Windows, MacOSX, Linux/Ubuntu) Wich logging library would you recommand? Currently, I think that boost::log is the most flexible one (you can even log to remotely!), but have not good performance. Pantheios is often cited but I don't have comparison points on performance and usage. I've used my own lib for a long time but I know it don't manage multithreading so it's a big problem, even if it's fast enough. Google Log seems interesting, I just need to test it but if you already have compared those libs and more, your advice might be of good use. Games are often performance demanding while complex to debug so it would be good to know logging libraries that, in our specific case, have clear advantages.

    Read the article

  • Understanding MotionEvent to implement a virtual DPad and Buttons on Android (Multitouch)

    - by Fabio Gomes
    I once implemented a DPad in XNA and now I'm trying to port it to android, put, I still don't get how the touch events work in android, the more I read the more confused I get. Here is the code I wrote so far, it works, but guess that it will only handle one touch point. public boolean onTouchEvent(MotionEvent event) { if (event.getPointerCount() == 0) return true; int touchX = -1; int touchY = -1; pressedDirection = DPadDirection.None; int actionCode = event.getAction() & MotionEvent.ACTION_MASK; if (actionCode == MotionEvent.ACTION_UP) { if (event.getPointerId(0) == idDPad) { pressedDirection = DPadDirection.None; idDPad = -1; } } else if (actionCode == MotionEvent.ACTION_DOWN || actionCode == MotionEvent.ACTION_MOVE) { touchX = (int)event.getX(); touchY = (int)event.getY(); if (rightRect.contains(touchX, touchY)) pressedDirection = DPadDirection.Right; else if (leftRect.contains(touchX, touchY)) pressedDirection = DPadDirection.Left; else if (upRect.contains(touchX, touchY)) pressedDirection = DPadDirection.Up; else if (downRect.contains(touchX, touchY)) pressedDirection = DPadDirection.Down; if (pressedDirection != DPadDirection.None) idDPad = event.getPointerId(0); } return true; } The logic is: Test if there is a "DOWN" or "MOVED" event, then if one of this events collides with one of the 4 rectangles of my DPad, I set the pressedDirectin variable to the side of the touch event, then I read the DPad actual pressed direction in my Update() event on another class. The thing I'm not sure, is how do I get track of the touch points, I store the ID of the touch point which generated the diretion that is being stored (last one), so when this ID is released I set the Direction to None, but I'm really confused about how to handle this in android, here is the code I had in XNA: public override void Update(GameTime gameTime) { PressedDirection = DpadDirection.None; foreach (TouchLocation _touchLocation in TouchPanel.GetState()) { if (_touchLocation.State == TouchLocationState.Released) { if (_touchLocation.Id == _idDPad) { PressedDirection = DpadDirection.None; _idDPad = -1; } } else if (_touchLocation.State == TouchLocationState.Pressed || _touchLocation.State == TouchLocationState.Moved) { _intersectRect.X = (int)_touchLocation.Position.X; _intersectRect.Y = (int)_touchLocation.Position.Y; _intersectRect.Width = 1; _intersectRect.Height = 1; if (_intersectRect.Intersects(_rightRect)) PressedDirection = DpadDirection.Right; else if (_intersectRect.Intersects(_leftRect)) PressedDirection = DpadDirection.Left; else if (_intersectRect.Intersects(_upRect)) PressedDirection = DpadDirection.Up; else if (_intersectRect.Intersects(_downRect)) PressedDirection = DpadDirection.Down; if (PressedDirection != DpadDirection.None) { _idDPad = _touchLocation.Id; continue; } } } base.Update(gameTime); } So, first of all: Am I doing this correctly? if not, why? I don't want my DPad to handle multiple directions, but I still didn't get how to handle the multiple touch points, is the event called for every touch point, or all touch points comes in a single call? I still don't get it.

    Read the article

  • How to find the window size in XNA

    - by Nick Van Hoogenstyn
    I just wanted to know if there was a way to find out the size of the window in XNA. I don't want to set it to a specific size; I would like to know what dimensions it currently displays as automatically. Is there a way to find this information out? I realize I probably should have found this information out (or set it myself manually) before working on the game, but I'm a novice and am now hoping to work within the dimensions I have already become invested in. Thanks!

    Read the article

  • Need help drawings planets in Java.

    - by d33j
    I am looking for help/links/notes/agorithms/URLs/examples on drawing/rendering spheres in pure Java (so that I can hopefully, one day, generate/render planets with various surfaces & atmospheres) So for the moment, i'd be pretty happy to be able to start off with just drawing a wireframed sphere(s). ps: I don't want to use external libraries like Java3D, JOGL or aftermarket engines like JMonkeyEngine, Would rather keep it as straight Java.

    Read the article

  • Interacting with scene from controller/app delegate cocos2d

    - by cjroebuck
    I'm attempting to make my first cocos2d (for iphone) multiplayer game and having difficulty understanding how to interact with a scene once it is running. The game is a simple turn-based one and so I have a GameController class which co-ordinates the rounds. I also have a GameScene class which is the actual scene that is displayed during a round of the game. The basic interaction I need is for the GameController to be able to pass messages to the GameScene class.. such as StartRound/StopRound etc. The thing that complicates this is that I am loading the GameScene with a LoadingScene class which simply initialises the scene and replaces the current scene with this one, so there is no reference from GameController to GameScene, so passing messages is quite tricky. Does anyone have any ways to get around this, ideally I would still like to use a Loading class as it smooths out the memory hit when replacing scenes.

    Read the article

  • one more time about loop that doesn't work

    - by unit
    I have asked a couple of questions about this for loop: String[] book = new String [ISBN_NUM]; bookNum.replaceAll("-",""); if (bookNum.length()!=ISBN_NUM) throw new ISBNException ("ISBN "+ bookNum + " must be 10 characters"); for (int i=0;i<bookNum.length();i++) { if (Character.isDigit(bookNum.charAt(i))) book[j]=bookNum.charAt(i); //this is the problem right here j++; if (book[9].isNotDigit()|| book[9]!="x" || book[9]!="X") throw new ISBNException ("ISBN " + bookNum + " must contain all digits" + "or 'X' in the last position"); } which will not compile. An answer I had from the other question I asked told me that the line where the error occurs is wrong in that bookNum.charAt(i) is an (immutable) string, and I can't get the values into a book array that way. What I need to do on my assignment is check an ISBN number (bookNum) to see that it is all numbers, except the last digit can be an 'x' (valid ISBN). Is this the best way to do it? If so, what the hell am I doing wrong? If not, what method would be a better one to use?

    Read the article

  • Rails 3 functional optionally testing caching

    - by Stephan
    Generally, I want my functional tests to not perform action caching. Rails seems to be on my side, defaulting to config.action_controller.perform_caching = false in environment/test.rb. This leads to normal functional tests not testing the caching. So how do I test caching in Rails 3. The solutions proposed in this thread seem rather hacky or taylored towards Rails 2: How to enable page caching in a functional test in rails? I want to do something like: test "caching of index method" do with_caching do get :index assert_template 'index' get :index assert_template '' end end Maybe there is also a better way of testing that the cache was hit?

    Read the article

  • Neat way of gettings position of my Object in linq collections

    - by Steve
    I currently have a object called Week. A week is part of a Season object. the season can contain many weeks. What I want to do is find the position of my week (is it the first week in the season (so #1) or is it the second (so #2). int i = 0; foreach ( var w in Season.Weeks.OrderBy(w => w.WeekStarts)){ if(w.Id == Id){ return i; } i+=1; } At the moment this is what I have. I order the weeks in a second by there start date to make sure they are in the correct order. and I cycle through them until I find the week that matches the week I am currently looking at. and return the int that I have been counting up.. I feel there should be a easier linq way to do this as it feels pretty messy!

    Read the article

  • How to prevent inheritance for some methods?!

    - by Dr TJ
    Hi How can I prevent inheritance of some methods or properties in derived classes?! public class BaseClass : Collection { //Some operations... //Should not let derived classes inherit 'Add' method. } public class DerivedClass : BaseClass { public void DoSomething(int Item) { this.Add(Item); // Error: No such method should exist... } }

    Read the article

  • Array sorting efficiency... Beginner need advice

    - by SoleSoft
    I'll start by saying I am very much a beginner programmer, this is essentially my first real project outside of using learning material. I've been making a 'Simon Says' style game (the game where you repeat the pattern generated by the computer) using C# and XNA, the actual game is complete and working fine but while creating it, I wanted to also create a 'top 10' scoreboard. The scoreboard would record player name, level (how many 'rounds' they've completed) and combo (how many buttons presses they got correct), the scoreboard would then be sorted by combo score. This led me to XML, the first time using it, and I eventually got to the point of having an XML file that recorded the top 10 scores. The XML file is managed within a scoreboard class, which is also responsible for adding new scores and sorting scores. Which gets me to the point... I'd like some feedback on the way I've gone about sorting the score list and how I could have done it better, I have no other way to gain feedback =(. I know .NET features Array.Sort() but I wasn't too sure of how to use it as it's not just a single array that needs to be sorted. When a new score needs to be entered into the scoreboard, the player name and level also have to be added. These are stored within an 'array of arrays' (10 = for 'top 10' scores) scoreboardComboData = new int[10]; // Combo scoreboardTextData = new string[2][]; scoreboardTextData[0] = new string[10]; // Name scoreboardTextData[1] = new string[10]; // Level as string The scoreboard class works as follows: - Checks to see if 'scoreboard.xml' exists, if not it creates it - Initialises above arrays and adds any player data from scoreboard.xml, from previous run - when AddScore(name, level, combo) is called the sort begins - Another method can also be called that populates the XML file with above array data The sort checks to see if the new score (combo) is less than or equal to any recorded scores within the scoreboardComboData array (if it's greater than a score, it moves onto the next element). If so, it moves all scores below the score it is less than or equal to down one element, essentially removing the last score and then places the new score within the element below the score it is less than or equal to. If the score is greater than all recorded scores, it moves all scores down one and inserts the new score within the first element. If it's the only score, it simply adds it to the first element. When a new score is added, the Name and Level data is also added to their relevant arrays, in the same way. What a tongue twister. Below is the AddScore method, I've added comments in the hope that it makes things clearer O_o. You can get the actual source file HERE. Below the method is an example of the quickest way to add a score to follow through with a debugger. public static void AddScore(string name, string level, int combo) { // If the scoreboard has not yet been filled, this adds another 'active' // array element each time a new score is added. The actual array size is // defined within PopulateScoreBoard() (set to 10 - for 'top 10' if (totalScores < scoreboardComboData.Length) totalScores++; // Does the scoreboard even need sorting? if (totalScores > 1) { for (int i = totalScores - 1; i > - 1; i--) { // Check to see if score (combo) is greater than score stored in // array if (combo > scoreboardComboData[i] && i != 0) { // If so continue to next element continue; } // Check to see if score (combo) is less or equal to element 'i' // score && that the element is not the last in the // array, if so the score does not need to be added to the scoreboard else if (combo <= scoreboardComboData[i] && i != scoreboardComboData.Length - 1) { // If the score is lower than element 'i' and greater than the last // element within the array, it needs to be added to the scoreboard. This is achieved // by moving each element under element 'i' down an element. The new score is then inserted // into the array under element 'i' for (int j = totalScores - 1; j > i; j--) { // Name and level data are moved down in their relevant arrays scoreboardTextData[0][j] = scoreboardTextData[0][j - 1]; scoreboardTextData[1][j] = scoreboardTextData[1][j - 1]; // Score (combo) data is moved down in relevant array scoreboardComboData[j] = scoreboardComboData[j - 1]; } // The new Name, level and score (combo) data is inserted into the relevant array under element 'i' scoreboardTextData[0][i + 1] = name; scoreboardTextData[1][i + 1] = level; scoreboardComboData[i + 1] = combo; break; } // If the method gets the this point, it means that the score is greater than all scores within // the array and therefore cannot be added in the above way. As it is not less than any score within // the array. else if (i == 0) { // All Names, levels and scores are moved down within their relevant arrays for (int j = totalScores - 1; j != 0; j--) { scoreboardTextData[0][j] = scoreboardTextData[0][j - 1]; scoreboardTextData[1][j] = scoreboardTextData[1][j - 1]; scoreboardComboData[j] = scoreboardComboData[j - 1]; } // The new number 1 top name, level and score, are added into the first element // within each of their relevant arrays. scoreboardTextData[0][0] = name; scoreboardTextData[1][0] = level; scoreboardComboData[0] = combo; break; } // If the methods get to this point, the combo score is not high enough // to be on the top10 score list and therefore needs to break break; } } // As totalScores < 1, the current score is the first to be added. Therefore no checks need to be made // and the Name, Level and combo data can be entered directly into the first element of their relevant // array. else { scoreboardTextData[0][0] = name; scoreboardTextData[1][0] = level; scoreboardComboData[0] = combo; } } } Example for adding score: private static void Initialize() { scoreboardDoc = new XmlDocument(); if (!File.Exists("Scoreboard.xml")) GenerateXML("Scoreboard.xml"); PopulateScoreBoard("Scoreboard.xml"); // ADD TEST SCORES HERE! AddScore("EXAMPLE", "10", 100); AddScore("EXAMPLE2", "24", 999); PopulateXML("Scoreboard.xml"); } In it's current state the source file is just used for testing, initialize is called within main and PopulateScoreBoard handles the majority of other initialising, so nothing else is needed, except to add a test score. I thank you for your time!

    Read the article

  • Show/hide using jQuery cookies

    - by Dilwin
    So I've created a simple tip box that fades in on page load, with an option to close the box. I'm trying to make the box hidden if the visitor clicks the close link. I'm fairly new to cookies, so I'm probably doing it all wrong, but this is what I have: $('#close').click(function(e) { jQuery.cookie('tip', 'hide', cookieOpts); $(this).parent('div.tip').fadeOut(1000); e.preventDefault(); }); jQuery.cookie('tip', 'show', cookieOpts); $('.tip').delay(500).fadeIn(1000); var shouldShow = jQuery.cookie('tip') == 'show'; var cookieOpts = {expires: 7, path: '/'}; if( shouldShow ) { $('.tip').delay(500).fadeIn(1000); } else { $('.tip').css('display', 'none'); }

    Read the article

  • CSS Float left question

    - by Minghui Yu
    <div id="slideshow-prevnext" class="slideshow-prevnext"> <a id="prev" class="left" href="#"><span class="invisible">Prev</span></a> <a id="next" class="right" href="#"><span class="invisible">Next</span></a> <a href="#" class="dot">&nbsp;</a> <a href="#" class="dot">&nbsp;</a> <a href="#" class="dot">&nbsp;</a> </div> I want the three <a href="#" class="dot">&nbsp;</a> appear on the left of and the two ("Prev" and "Next") on the right. How can I do it? I tried float:left but does not work. Edit: CSS is too long to post. Development site is here at : http://site2.ewart.library.ubc.ca/

    Read the article

  • Counting total sum of each value in one column w.r.t another in Perl

    - by sfactor
    I have tab delimited data with multiple columns. I have OS names in column 31 and data bytes in columns 6 and 7. What I want to do is count the total volume of each unique OS. So, I did something in Perl like this: #!/usr/bin/perl use warnings; my @hhfilelist = glob "*.txt"; my %count = (); for my $f (@hhfilelist) { open F, $f || die "Cannot open $f: $!"; while (<F>) { chomp; my @line = split /\t/; # counting volumes in col 6 and 7 for 31 $count{$line[30]} = $line[5] + $line[6]; } close (F); } my $w = 0; foreach $w (sort keys %count) { print "$w\t$count{$w}\n"; } So, the result would be something like Windows 100000 Linux 5000 Mac OSX 15000 Android 2000 But there seems to be some error in this code because the resulting values I get aren't as expected. What am I doing wrong?

    Read the article

  • JSP cant find bean Class using "" modifiers

    - by Ravana
    Hey I'm using Netbeans for my IDE and I'm getting an error when I try to run my EJB program. I get an error when I declare and give the path of the class in my JSP to a bean. <jsp:useBean id="book" class="BookBean.Book" scope="application" /> <jsp:setProperty name="book" property="*" /> When I run the program I get this error javax.servlet.ServletException: java.lang.InstantiationException: class BookBean.Book : java.lang.IllegalAccessException: Class java.beans.Beans can not access a member of class BookBean.Book with modifiers "" and java.lang.InstantiationException: class BookBean.Book : java.lang.IllegalAccessException: Class java.beans.Beans can not access a member of class BookBean.Book with modifiers "" I removed the "" and put in '' to see if that works, but it doesn't. Any idea? I also put a breakpoint there and it def. is the root of the problem. Thanks.

    Read the article

  • Compilation Error on Recursive Variadic Template Function

    - by Maxpm
    I've prepared a simple variadic template test in Code::Blocks, but I'm getting an error: No matching function for call to 'OutputSizes()' Here's my source code: #include <iostream> #include <typeinfo> using namespace std; template <typename FirstDatatype, typename... DatatypeList> void OutputSizes() { std::cout << typeid(FirstDatatype).name() << ": " << sizeof(FirstDatatype) << std::endl; OutputSizes<DatatypeList...>(); } int main() { OutputSizes<char, int, long int>(); return 0; } I'm using GNU GCC with -std=C++0x. Using std=gnu++0x makes no difference.

    Read the article

  • How to use boost normal distribution classes?

    - by David Alfonso
    Hi all, I'm trying to use boost::normal_distribution in order to generate a normal distribution with mean 0 and sigma 1. The following code uses boost normal classes. Am I using them correctly? #include <boost/random.hpp> #include <boost/random/normal_distribution.hpp> int main() { boost::mt19937 rng; // I don't seed it on purpouse (it's not relevant) boost::normal_distribution<> nd(0.0, 1.0); boost::variate_generator<boost::mt19937&, boost::normal_distribution<> > var_nor(rng, nd); int i = 0; for (; i < 10; ++i) { double d = var_nor(); std::cout << d << std::endl; } } The result on my machine is: 0.213436 -0.49558 1.57538 -1.0592 1.83927 1.88577 0.604675 -0.365983 -0.578264 -0.634376 As you can see all values are not between -1 and 1. Thank you all in advance!

    Read the article

  • Android 2.1 NullPointerException with TabWidgets

    - by ninjasense
    I have an issue I have not been able to figure out and it is only happening on devices running <2.1. It works fine on android 2.2. I have ansynchronous task that displays a loading dialog while it loads all the tabs. Here is the code for the TabActivity: public class OppTabsView extends TabActivity { Dialog dialog; String errorText; boolean save; final int OPP_SAVE = 0; public static boolean edited; public void onCreate(Bundle icicle) { try { super.onCreate(icicle); new DoInBackground().execute(); } catch (Exception e) { Toast.makeText(this, "Error occured. Please try again later.", Toast.LENGTH_SHORT).show(); } } @Override protected void onResume() { super.onResume(); } @Override protected void onStop() { super.onStop(); } @Override protected void onPause() { super.onPause(); } public boolean onCreateOptionsMenu(Menu menu) { menu.add(0, OPP_SAVE, 0, "Test"); return true; } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case OPP_SAVE: save = true; new DoInBackground().execute(); return true; } return false; } public void LoadOpp() { handler.sendEmptyMessage(0); } public void SaveOpp() { DoStuff(); } public void LoadLayout() { setContentView(R.layout.view_opptabs); /* TabHost will have Tabs */ TabHost tabHost = (TabHost) findViewById(android.R.id.tabhost); /* * TabSpec used to create a new tab. By using TabSpec only we can able * to setContent to the tab. By using TabSpec setIndicator() we can set * name to tab. */ /* tid1 is firstTabSpec Id. Its used to access outside. */ TabSpec firstTabSpec = tabHost.newTabSpec("tid1"); TabSpec secondTabSpec = tabHost.newTabSpec("tid1"); TabSpec thirdTabSpec = tabHost.newTabSpec("tid1"); /* TabSpec setIndicator() is used to set name for the tab. */ /* TabSpec setContent() is used to set content for a particular tab. */ firstTabSpec.setIndicator("General", getResources().getDrawable(R.drawable.tab_moneybag)) .setContent(new Intent(this, OppTabGeneral.class)); secondTabSpec.setIndicator("Details", getResources().getDrawable(R.drawable.tab_papers)).setContent( new Intent(this, OppTabDetails.class)); thirdTabSpec.setIndicator("Contact", getResources().getDrawable(R.drawable.tab_contact)).setContent( new Intent(this, OppTabContact.class)); /* Add tabSpec to the TabHost to display. */ tabHost.addTab(firstTabSpec); tabHost.addTab(secondTabSpec); tabHost.addTab(thirdTabSpec); } private void do_update() { if (save) { SaveOpp(); } else { LoadOpp(); } } Handler handler = new Handler() { public void handleMessage(Message msg) { LoadLayout(); } }; private class DoInBackground extends AsyncTask<Void, Void, Void> implements DialogInterface.OnCancelListener { protected void onPreExecute() { String verb = "Connecting"; if (save) { verb = "Saving"; } dialog = ProgressDialog.show(OppTabsView.this, "", verb + ". Please Wait...", true, true, this); } protected Void doInBackground(Void... v) { do_update(); return null; } protected void onPostExecute(Void v) { dialog.dismiss(); } public void onCancel(DialogInterface dialog) { cancel(true); dialog.dismiss(); finish(); } } } Here is the stack trace from the error: java.lang.NullPointerException at android.widget.TabWidget.dispatchDraw(TabWidget.java:206) at android.view.ViewGroup.drawChild(ViewGroup.java:1529) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.ViewGroup.drawChild(ViewGroup.java:1529) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.ViewGroup.drawChild(ViewGroup.java:1529) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.View.draw(View.java:6538) at android.widget.FrameLayout.draw(FrameLayout.java:352) at android.view.ViewGroup.drawChild(ViewGroup.java:1531) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.ViewGroup.drawChild(ViewGroup.java:1529) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.View.draw(View.java:6538) at android.widget.FrameLayout.draw(FrameLayout.java:352) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830) at android.view.ViewRoot.draw(ViewRoot.java:1349) at android.view.ViewRoot.performTraversals(ViewRoot.java:1114) at android.view.ViewRoot.handleMessage(ViewRoot.java:1633) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4363) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) at dalvik.system.NativeStart.main(Native Method) I have tried stepping through it but the error seems to come out of no where, not at a specific line. Any help is greatly appreciated.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >