How to use Android Invalidate()
<p>In my main activity I have defined two views and a menu:</p>

<p>Views:
1. Custom view game
2. Button btn</p>

<p>Menu:
1. Open item for opening a file </p>

<p>The menu layout is defined in a different activity</p>

<p>Basically, when the main activity starts, it draws the custom view that doesn't have anything, and the button. Then I load the file using the open in the menu. It brings up a list of files in the /sdcard dir and I pick the file from the list. Then the onListItemClick() parses the file and updates the data structure in the custom view. Then I press back to return to the main activity. Now I'd expect to see the redraw after pressing the button but it doesn't seems to do anything. I've implemented the OnClickListener() for the button and call the game.invalidate(). But it doesn't seem to redraw the custom view immediately upon button click. I have to exit the app( back button) then reopen the app to see the redraw. I've read other posts regarding the invalidate() not redrawing the view immediately. It only pushes it to a queue and Android will take action once it's free to do so. I guess thing I don't understand is that what in my app is holding Android from taking action. </p>

<p>Snippets of code</p>

<pre><code>//Main Activity
public class someActivity extends Activity {

someView myView;

@Override
public void onCreate(Bundle savedInstanceState)
{
     super.onCreate(savedInstanceState);
     LinearLayout layout = new LinearLayout(this);
     layout.setOrientation(LinearLayout.VERTICAL);
     Button btn1 = new Button(this);
     btn1.setOnClickListener(forward);
     myView = new someView(this);
     layout.addView(myView);
     layout.addView(btn1);
     setContentView(layout);
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item)
{
    switch (item.getItemId())
    {
    case R.id.open:
        Intent myIntent = new Intent();
        myIntent.setClass(this, DirectoryBrowser.class);
        startActivityForResult(myIntent,0);
        return true;
    case R.id.save:
        return true;
    default:
        return super.onOptionsItemSelected(item);

    }
}

private OnClickListener forward = new OnClickListener()
{
    public void onClick(View v)
    {
        myView.invalidate();

    }
};

//DirectoryBrowser Activity
public class DirectoryBrowser extends ListActivity 
{
private List&lt;String&gt; items = null;

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(R.layout.open);
    getFiles(new File("/sdcard").listFiles());
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id){
    int selectedRow = (int)id;
    if(selectedRow == 0){
        getFiles(new File("/sdcard").listFiles());
    }else{
        File file = new File(items.get(selectedRow));
        if(file.isDirectory()){
            getFiles(file.listFiles());
        }else{
                try
                {
                                         //Parse file and update myView.data
                                    }
                catch (FileNotFoundException e) 
                {
                    Log.e("ERROR","File Not Found");
                }
        }
    }
}

//Custom View someView
//...

@Override
public void onDraw(Canvas canvas) 
{
         //Redraw view here

}
</code></pre>
