I'm calling the fragment from the main activity:


AdExample.java source code:

public class AdExample extends Fragment {

    private ListView listView;

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        // getting access to layout
        View view = inflater.inflate(R.layout.ad_example, container, false);
        listView = (ListView) view.findViewById(R.id.listView);

        MovieAdapter adapter = new MovieAdapter(getActivity(), initData());


        return view;

    private List<MovieItem> initData () {
        List<MovieItem> list = new ArrayList<MovieItem>();

        list.add(new MovieItem("Item1", "Desc1", 2014));
        list.add(new MovieItem("Item2", "Desc2", 2014));
        list.add(new MovieItem("Item3", "Desc3", 2014));

        return list;

But as a result I get a blank ListView. Have I missed something in the above code?



Here is MovieAdapter.java source code:

public class MovieAdapter extends BaseAdapter {

    private List<MovieItem> list;
    private LayoutInflater layoutInflater;

    public MovieAdapter(Context context, List<MovieItem> list) {
        this.list = list;
        layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    public int getCount() {
        return 0;

    public Object getItem(int position) {
        return list.get(position);

    public long getItemId(int position) {
        return position;

    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
        if (view == null) {
            view = layoutInflater.inflate(R.layout.movie_item, parent, false);

        TextView name = (TextView) view.findViewById(R.id.nameText);

        return view;

    private MovieItem getMovieItem(int position ) {
        return (MovieItem) getItem(position);

following problem: I use a custom ArrayAdapter and implement the ViewHolder pattern, when showing a list of items. I also use convertViews. On loading everything is fine and list items are shown in correct, alternating colors.

But when I scroll fast up and down, the colors change and are not alternating anymore... for Example when loading: green, blue, green, blue ... After scrollin: green, blue, green, green, green, green....

Here is some Code:

    public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context

    ViewHolder holder;

    StoreTemplate curr = templates.get(position);

    if (convertView == null) {
        convertView = inflater.inflate(R.layout.template_store_rowlayout,
                parent, false);
        holder = new ViewHolder();
        holder.name = (TextView) convertView
        // more attr skipped here...
    } else {
        holder = (ViewHolder) convertView.getTag();

    // more attr set here...

    // this changes background
    if ((position % 2) == 0) {

    // code skipped here

    return convertView;

How can I assure, that rows are ALWAYS colored altenately, even if I scroll, or search and reload the list?

I'm trying to delete a database entirely if onUpgrade gets called. According to this SO question: How to delete SQLite database from Android programmatically I can just call context.deleteDatabase(String dbName), but I can't get to context in the onUpgrade method. In onUpgrade there is a db object that is passed in, and I see that you can use a db.deleteDatabase() method, but it takes a file. I don't have the db file. Is there any way to do db.deleteSelf or something similar? I know that I could just drop tables and such instead of totally deleting the database, but my db structure has totally changed and I would rather just call deleteDb(); and then onCreate(db); again.

I'm using Delphi XE 6 version and I have created Android Application and when i'm trying to run that application in Emulator, the application is running in Android 4.3 and that application is not running in the lower versions of the Emulator. Is it possible to make the android application run in lower version of Android OS by changing any of the setting. And I didn't test by running the application in mobile phones. Currently I'm i have tested the application in Emulators(Default emulator, BlueStacks and Greymotion). Please suggest me the good solution.

I'm running Windows 8 and the newest version of Android Studio. The device manager does not recognize any android devices.

I've tried numerous solutions, such as the ones suggested here. I've tried updating the drivers through the Device Manager several times, but it says that the best driver software is already installed and up-to-date.

My Nexus 5 is plugged in, developer mode is on, USB debugging is enabled, unknown sources are allowed, and I've tried toggling between MTP and PTP mode. I'm not sure what to do at this point. Any help or advice is appreciated. Thanks!

Im using parse and sometimes my query will return an empty list. I want to be able to handle this condition by showing a text in the text view. The code seems to be working fine when the list does return objects but not when the list is empty. Not sure what the error but the app crashes.

public class ReviewPage extends Activity {
    String obj, rName, rating, reviews;
    TextView txtview;

    protected void onCreate(Bundle savedInstanceState) {
        Intent i = getIntent();
        obj = i.getStringExtra("RestName");
        txtview = (TextView) findViewById(R.id.review1);

    public void getReview(String obj) {
        ParseQuery<ParseObject> query = ParseQuery.getQuery("Reviews");
        query.whereEqualTo("Restraunt", obj);
        query.findInBackground(new FindCallback<ParseObject>() {
            public void done(List<ParseObject> reviewList, ParseException e) {
                if (e == null) {
                    ParseObject review = reviewList.get(0);
                    if (review == null) {
                        txtview.setText("No Reviews yet");
                    } else {
                        rName = review.getString("Name");
                        rating = review.getString("Rating");
                        reviews = review.getString("review");
                        txtview.setText(rName + "\n" + reviews);
                } else {
                    txtview.setText("No Reviews yet");

    public void Submit(View v) {
        final EditText edit = (EditText) findViewById(R.id.review);
        final EditText edit1 = (EditText) findViewById(R.id.rName);
        String rName = edit1.getText().toString();
        String review = edit.getText().toString();

        ParseObject newReview = new ParseObject("Reviews");
        newReview.put("Name", rName);
        newReview.put("review", review);
        newReview.put("Restraunt", obj);

    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.review_page, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        return super.onOptionsItemSelected(item);

I am using the admob service which google provides to enable the developer to put ad's into their app. The app is displaying fine, however I want the app to appear at the bottom of the screen, as opposed to the top.

Given my below XML code, how would I do this?

Thanks for any help!

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" >

    <LinearLayout android:layout_alignParentTop="true"
        ads:adUnitId="" >



I am also using this java code:

 adView = (AdView) this.findViewById(R.id.adView);
        // Create an ad.
        adView = new AdView(this);

        //LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout);
        RelativeLayout layout = (RelativeLayout) findViewById(R.id.linearLayout);

        AdRequest adRequest = new AdRequest.Builder()

how to refresh automatically data in android application When input entering from database or service.How to trigger to android application

WinAPI is focused primarily on the C family, but how do new programming languages use those features without creating their own runtime/interpreter type thing? Do they hook directly into the DLL files? kernel32.dll contains most of those functions right?


I am developing an app with html5 pages locally stored in the assets folder. I have included a database with some php scripts, is it still possible to run in WebView?

I cannot find the answer to how much data will this update consume? Some forums mentioned that I should have almost 1.5 GB of free space in my phone before I update it, but there is no information as to what is the file size of this update.

Please advice.

I'm developing a cocos2dX game. I use box2d for physics simulation. I'm trying to add a circular body and a rectangular body. Here is my code

// Create circular sprite and body
CCSprite* ball_sprite = CCSprite::create("ball.png");

b2BodyDef ballBodyDef;
ballBodyDef.type = b2_dynamicBody;
ballBodyDef.position.Set(screenSize.width/PTM_RATIO, screenSize.height/2/PTM_RATIO);//im running it in an iphone retina and screensize is 640x960
ballBodyDef.userData = ball_sprite;
ball_body = _world->CreateBody(&ballBodyDef);

b2CircleShape ballshape;
ballshape.m_radius = BALL_SIZE/2;

b2FixtureDef ballShapeDef;
ballShapeDef.shape = &ballshape;
ballShapeDef.density = 100.0f;
ballShapeDef.friction = 0.5f;
ballShapeDef.restitution = 0.7f;

// Create rectangular sprite and body
CCSprite* block_sprite = CCSprite::create("HelloWorld.png");

b2BodyDef blockBodyDef;
blockBodyDef.type = b2_staticBody;
blockBodyDef.position.Set(0, screenSize.height/2/PTM_RATIO);
blockBodyDef.userData = block_sprite;
block_bodie = _world->CreateBody(&blockBodyDef);

b2PolygonShape blockshape;
b2FixtureDef blockShapeDef;
blockShapeDef.shape = &blockshape;
blockShapeDef.density = 100.0f;
blockShapeDef.friction = 0.5f;
blockShapeDef.restitution = 0.7f;

The rectangular body is shown in the screen as expected.

But the circular body is not shown in the screen.

When I printed the position of circular body in the update function, the positions are large numbers around 2000. And this position is different each time I run the programm.

If the rectangular body is not added(commenting the line block_bodie->CreateFixture(&blockShapeDef);) then the circular body is shown in the screen as I expected.

What I'm doing wrong here?

Thanks in advance.

Was hoping someone could help with this please? I've scanned through the forum and apple docs and can't find anything that matches my problem exactly.

I'm trying to animate a custom 'Composite' UIView derived class (with overidden drawRect) by changing a custom colour property (not one of the standard view properties like centre, alpha, backgroundColour etc), calling setNeedsDisplay and redrawing the view using drawRect over X seconds duration to produce a slow colour change from say, red to blue.

At the moment, all Composite::drawRect does internally is clear the context (the view has a default background colour set to clear) and fill the view using the colour provided. This works fine the first time it's called - the view appears on screen in the correct red colour.

My problem is that when I try to animate the view by updating the colour property, even though drawRect is being called everytime I call setNeedsDisplay and the colour being fed into the view instance is correct the view doesn't update on screen until I stop calling setNeedsDisplay (or rather, stop updating the custom view colour property). It's like every call to setNeedsDisplay pushes the view to the back of a list so it doesn't get updated on screen until it stops getting called (even though drawRect is being called).

For example - trying to change the colour from red to blue over 10 seconds, the view stays red for 10 seconds, then turns to blue in a single frame at the end of the property changing (and presumably when I stop calling setNeedsDisplay) rather than a slow fade between the two over the time duration.

Any ideas what's going on? I'm guessing I need to animate this using apple's own animation property stuff but I'd really prefer not to - I'm trying to make this cross platform if possible and I don't see why my own method shouldn't work.

The basics:

In case it matters, my composite view instance is a subview of an UIImageView. (I know imageview drawRect doesn't get called but I can't imagine this is a problem for it's subviews - after all, my Composite::drawRect is definitely being called).

I'm setting the right colour on my view instance - I've debug printed this to be sure - so the colour provided to the view goes from red to blue over however many seconds / frames.

I'm setting setNeedsDispay and drawRect is being called every time - again, debug printing confirms this.

This is happening over multiple frames and the app goes through the drawing update at the end of every frame - I.e I'm not blocking the render thread or anything - the app runs fine, it just doesn't update the view on screen even though its drawRect is being called, until I stop manipulating the property. Someone mentioned a similar problem where they were blocking the render thread in a single frame but I'm definitely not doing anything like that.

I've tried messing around with the following but they all produced the same results (i.e. view changed from red to blue in a single frame rather than a slow change over).

  • Updating the colour every frame but only calling setNeedsDisplay on my view every Xth frame (5, 10, 20, 30 etc)

  • Updating the colour every frame but not calling setNeedsDisplay unless the corresponding drawRect call from the last setNeedsDisplay has happened (i.e. set a flag to false in SetColour func, set same flag to true in drawRect, test against it when decided to call setNeedsDisplay) - same results.

  • setting the view bounds with ContentMode set to redraw to force an update - same results

  • tried calling setNeedsDisplay on the parent image view too - no change.

I'm guessing that this just isn't possible - can anyone explain why its not updating the v view onscreen even though drawRect is being called? Any ideas how I should do this? I don't think I would be able to do what I want to do if I tried animated one of the default view properties using apple's internal animation system but if I've got to use that....



I want to use social login feature of Gigya SDk in my iOS app. But when user logs in using Gigya SDK from my mobile application,how come my server will get notified about this event?

I found an open source project (link here) that I need to implement in my next project. The problem is that the framework is setup as a storyboard project, which I will not use. I have problems in converting this project to a non-storyboard, non .xib project. I asked already some help in the comments of another SA question and on the gitpage of this framework but time is shrinking.

I keep getting this error: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'could not dequeue a view of kind: UICollectionElementKindCell with identifier RPSlidingCellIdentifier - must register a nib or a class for the identifier or connect a prototype cell in a storyboard' even though the class/nib is registered.

A push in the right direction would be appreciated a lot. I added my test project to my dropbox for your convenience.

The Cell class gets registered in RPSlidingMenuViewController.m viewDidLoad

First time poster, long time observer.

I am using storyboards for an app I am working on at present, and require more of a transition than just going forward, for going back in particular. Whenever i use this segue i have for going back through a menu, the next button that is clicked on to go to another ViewController, will crash the whole app!

No idea whats going on, i am using this in the implementation file

#import "SlideLeftSegue.h"

@implementation SlideLeftSegue

- (void)perform{
    UIView *sv = ((UIViewController *)self.sourceViewController).view;
    UIView *dv = ((UIViewController *)self.destinationViewController).view;

    UIWindow *window = [[[UIApplication sharedApplication] delegate] window];
    dv.center = CGPointMake(sv.center.x - sv.frame.size.width, dv.center.y);
    [window insertSubview:dv belowSubview:sv];

    [UIView animateWithDuration:0.4
                         dv.center = CGPointMake(sv.center.x,
                         sv.center = CGPointMake(sv.center.x + sv.frame.size.width,
                     completion:^(BOOL finished){
                         [[self destinationViewController]
                          dismissViewControllerAnimated:NO completion:nil];


This is my header file

#import <UIKit/UIKit.h>

//  Move to the previous screen with slide animation.

@interface SlideLeftSegue : UIStoryboardSegue


I am still learning, so if you have any idea whats happening, id appreciate an explanation at a beginner level.



When using the native iOS share dialog UIActivityViewController inside you own App and starting to share a link via the Facebook icon a SocialUIService is in the background crawling the link/website for additional information.

What HTTP user-agent has this SocialUIService service?

I am creating an app where a square moves back and forth on the screen (which I have accomplished) and the have a red button stop the movement when held down (also accomplished), and then resume the square's movement when the user releases the button (question). I use to voids for moving to the left (moveSquare1) and to the right (moveSquare2). I can't figure out how to make the NSTimer know to resume the timer with whichever selector it was using before. Here is the code for releasing the button:

-(IBAction) StopAction{

SquareTimer1 = [NSTimer scheduledTimerWithTimeInterval:0.003 target:self selector:@selector(moveSquare2 || moveSquare1) userInfo:nil repeats:YES];


This doesn't work, because the NSTimer doesn't know which selector (moveSquare1 or moveSquare2) to use, and I don't know how to tell it. How can I code this?

Thank you in advance.

Ok to save typing it all out again...

Is there a solution to this issue now we are almost at ios8?

iOS Sandbox Test User account Subscription Management

I'm programming with XCode just for a few weeks, so I'm not a pro. But now I'm having a problem which I think is very basic but I can't solve it. I've created a new project with an UITableViewController with static cells and filled them with UILabels. I also created a MainTableView.h and a MainTableView.m. In the .m file I'v deleted the three functions (numberOfRowsInSection, numberOfSections? and cellForRowAtIndexPath), just as it's shown in many tutorials. Although it's not working. If I build and start it, the tables are correctly shown but not their content(the labels). What am I doing wrong ?

Is there an open source library for a calendar like in Any.Do's Cal app for iPhone? I'd like to have the functionality of a one row week with a swipe, and the functionality of scroll down to reveal the whole month calendar. I've found Kal and Vurig-Calendar but they don't seem to have the functionality I'm looking for.