Search Results

Search found 4 results on 1 pages for 'bhups'.

Page 1/1 | 1 

  • What's the best way to check if the view is visible on the window?

    - by bhups
    What's the best way to check if the view is visible on the window? I have a CustomView which is part of my SDK and anybody can add CustomView to their layouts. My CustomView is taking some actions when it is visible to the user periodically. So if view becomes invisible to the user then it needs to stop the timer and when it becomes visible again it should restart its course. But unfortunately there is no certain way of checking if my CustomView becomes visible or invisible to the user. There are few things that I can check and listen to: onVisibilityChange //it is for view's visibility change, and is introduced in new API 8 version so has backward compatibility issue onWindowVisibilityChange //but my CustomView can be part of a ViewFlipper's Views so it can pose issues onDetachedFromWindows //this not as useful onWindowFocusChanged //Again my CustomView can be part of ViewFlipper's views. So if anybody has faced this kind of issues please throw some light.

    Read the article

  • Whats the best data-structure for storing 2-tuple (a, b) which support adding, deleting tuples and c

    - by bhups
    Hi So here is my problem. I want to store 2-tuple (key, val) and want to perform following operations: - keys are strings and values are Integers - multiple keys can have same value - adding new tuples - updating any key with new value (any new value or updated value is greater than the previous one, like timestamps) - fetching all the keys with values less than or greater than given value - deleting tuples. Hash seems to be the obvious choice for updating the key's value but then lookups via values will be going to take longer (O(n)). The other option is balanced binary search tree with key and value switched. So now lookups via values will be fast (O(lg(n))) but updating a key will take (O(n)). So is there any data-structure which can be used to address these issues? Thanks.

    Read the article

  • HTML5 Video Element on iPad doesn't fire onclick?

    - by bhups
    I am using the video element in my HTML as following:<div id="container" style="background:black; overflow:hidden;width:320px;height:240px" <video style="background:black;display:block" id="vdo" height="240px" width="320px" src="http://mydomain/vid.mp4"</video</div And in javascript I am doing this:var video=document.getElementById('vdo'); var container=document.getElementById('container'); video.addEventListener('click', function(e) { e.preventDefault(); console.log("clicked"); }, false); container.addEventListener('click', function(e) { e.preventDefault(); console.log("clicked"); }, false); On desktop safari/chrome everything is working fine. I can see two "clicked" in the console. But on ipad there is nothing. First I tried with iOS versin 3.2, then I updated it to the latest one 4.2.1 without any success.I found a similar question HTML5 Video Element on iPad doesn't fire onclick or touchstart events? where it suggests not to use controls in video tag and I am not using it.

    Read the article

  • Add button to a layout programmatically

    - by mmmbaileys
    I'm having trouble adding a button to a layout that I've created in XML. Here's what I want to achieve: //some class else { startActivity(new Intent(StatisticsScreen.this, ScreenTemperature.class)); } //// //ScreenTemperatureClass @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //this is where I call another class that //displays a nice graph setContentView(new GraphTemperature(getApplicationContext())); } I want to add a Button to this new screen so that it'll appear below the graph. I've tried creating a LinearLayout view, then create a Button and add it to this view but I just get NullPointerExceptions.. Any help would be appreciated. Thanks EDIT#1 Here's what I've tried using that created a NullPointerException and 'force close': Button buybutton; LinearLayout layout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new GraphTemperature(getApplicationContext())); layout = (LinearLayout) findViewById(R.id.statsviewlayout); Button buyButton = new Button(this); buyButton.setText(R.string.button_back); buyButton.setLayoutParams(new LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); layout.addView(buyButton); } And here's the logcat error: ERROR/AndroidRuntime(293): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.weatherapp/com.weatherapp.ScreenTemperature}: java.lang.NullPointerException ERROR/AndroidRuntime(293): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663) ERROR/AndroidRuntime(293): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) ERROR/AndroidRuntime(293): at android.app.ActivityThread.access$2300(ActivityThread.java:125) ERROR/AndroidRuntime(293): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) theres abviously more lines to do with this error in logcat, not sure if you want it? EDIT#2 So i tried bhups method: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GraphTemperature GT = new GraphTemperature(getApplicationContext()); layout = (LinearLayout) findViewById(R.id.statsviewlayout); Button buyButton = new Button(this); buyButton.setText(R.string.button_back); buyButton.setLayoutParams(new LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); layout.addView(GT); // line 27 layout.addView(buyButton); setContentView(layout); } This method produced the same logcat error as above, NullPointerException, indicating it was something to do with line no. 27 which is the layout.addView line of code. Any ideas? Thanks again

    Read the article

1