Archive for the ‘Programming’ Category

WordPress: get posts within the loop

Click here to read WordPress: get posts within the loop

This post will explain how to get posts at the WordPress loop, so you can place code (probably advertisement code) after a specific post (first, second, third) or at intervals (e.g.: every 3 posts).

Before starting, it is a good idea to create a backup copy of your theme’s index.php file, just in case anything goes wrong.

This is a five page post, so here is the page index:

  1. Get the first post
  2. Get the 2nd, 3rd or any other post
  3. Get odd/even posts
  4. Get post intervals
  5. Final considerations

Let’s begin by finding where to place the code. That’s why we need to find the WordPress Loop in the index.php file.

Continue reading: “WordPress: get posts within the loop”

Access Activity class from View

Click here to read Access Activity class from View

So, it begins! This is the first on this blog!

Let’s start with a Android Programming tip: how to access the Activity from an instantiated View object.

The first thing to do is consider if you really need to call an Activity from a View. Take some time to analyze your classes and their relationships. Probably, the variable/method you need to access doesn’t have to be a member of the Activity class. In that case, think about placing that variable/method inside the View or create a new class that has variables/methods which can be accessed by both Activity and View. Unless an Activity variable or method (e.g. Activity.finish() ) needs to be called from the View, there is no need to try to access the Activity from the current View.

But if you need to access a method/variable of the calling Activity from the View, here is how it’s done:

Continue reading: “Access Activity class from View”

Page 20 of 20« First...10...1617181920