Android ListView

I was browsing the interwebs trying to find an example of how to do a ListView on Android through XML. However, there were not very many good examples. There were many that talked about creating a new activity, but I wanted my list view to be within another so that was no option. I finally stumbled upon this website that talks about how to create the listview and add everything to it without creating a new activity. Here is the link:

Android ListView and ListActivity – Tutorial

Tags: , , ,

Changing Android Views Dynamically

So I was trying to figure out a way to change a view at runtime, depending on the click of different buttons. I came across one site that seemed promising so I decided that I would post it here.

Android: How to load layout xml files dynamically during runtime

In addition, I found that this stackoverflow post was helpful as well:

Dynamically change view inside view in Android

In the end I had to do some work myself to make everything work, and this is what I ended up accomplishing:

listView.setOnItemClickListener(new OnItemClickListener()
		listView.setOnItemClickListener(new OnItemClickListener()
{
	public void onItemClick(AdapterView<?> parent, View view, int position, long id)
	{
		LinearLayout contentView = (LinearLayout) findViewById(R.id.contentView);
		contentView.removeAllViews();

		LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View subView = li.inflate(R.layout.mylayoutfile, null);
		contentView.addView(subView, new LinearLayout.LayoutParams(contentView.getLayoutParams().width, contentView.getLayoutParams().height));
	}
});

Of course the above need the R.layout.mylayoutfile replaced with whatever is desired, and the appropriate imports taken care of, but this should help. The very important part is the contentView.removeAllViews() because adding views on top of views doesn’t work.

Tags: , , ,

Android Rectangle Shape XML

I was having a hard time with this, and being new to Android I found the solution to this not that easy. My problem: I wanted to simply try creating a rectangle through XML and display it on screen. I tried using DroidDraw to no avail, and this tool seems like it could be interesting but it didn’t really help me with what I wanted. So after some research, I finally figured out how to draw a rectangle in XML:

1. Create your rectangle shape in a separate XML than your layout, for example res/drawable/rectangle.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
             android:shape="rectangle">
  <solid android:color="#ffffff"/>
  <stroke android:width="3dp"
          android:color="#ff000000"/>
  <padding android:left="0dp"
           android:top="0dp"
           android:right="0dp"
           android:bottom="0dp"/>
  <corners android:radius="0dp"/>
</shape>

2. In your layout XML create an ImageView (I’ve seen examples of View, but I just used ImageView)

<ImageView
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/rectangle"
/>

3. Voila! If you build and launch your application you should see a white rectangle now.

Tags: , , , ,

No resource identifier found for attribute ’showAsAction’ in package android

Playing around with some of the widgets available in Android 3.0 and there is the Action Bar that is used everywhere (such as in the Email client) and it is cool. I was playing around for the longest time to try and get it to build, but it seems that it just didn’t want it. I kept getting the message

No resource identifier found for attribute 'showAsAction' in package android

and I did lots of research to figure out why and I kept trying to change the AndroidManifest.xml in my project to this:

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" />

Which only solves part of the problem. The other problem was that it seems that everything was trying to build with Android API 9 instead of 11, which I discovered in the project.properties page and it looked like this:

target=android-9

After changing it to android-11, everything compiled and worked properly. The only thing that I’m worried about is the fact that the file contains a warning “Do not modify this file — YOUR CHANGES WILL BE ERASED!” Although it doesn’t seem to have happened yet, at the very least I’ll go and change it again later if need be.

Tags: , , , , ,

Android Development with Visual Studio

Me, being the programmer that I am, decided to play around with some Android development. Well, at first I wasn’t too happy with a lot of things. First, Android uses Java as it’s main language – something that I really detest. Second, it requires Cygwin for development (sorta). Third, no Visual Studio integration.

Java isn’t absolutely necessary to create Android Apps, however it is akin to ObjectiveC on iOS. It has to be used for some stuff, but for the most part you don’t really have to use it if you don’t want to. Also, you don’t absolutely need Cygwin for development (more info on that in a bit).

In regards to the problem with Visual Studio integration: After some quick google searches it was easy to find some stuff that allows you to use Visual Studio to develop Android apps. There is this great addin for Visual Studio called vs-android, and it allows you to build directly from Visual Studio (including generating the apk and signing it). The next great thing about it is that you don’t need cygwin to build your apps.

vs-android Google Code Project

Then comes the problem of debugging in Visual Studio, and I found a “solution” to that. Its called WinGDB and it seems like it will provide all of the necessary stuff to debug Android programs in Visual Studio.

Android Debugging, Visual Studio style!

However, after playing around with it for a few hours I wasn’t able to get it working… at all. Worse yet, it seems that the product will no longer be free in a bit. Although, debugging isn’t available from Visual Studio, maybe you can still continue to work with something like Eclipse for your C++ debugging too – no idea if it will work though.

And again, me being the programmer that I am, since WinGDB doesn’t work I decided to write my own program to do what it does inside Visual Studio. It seems that the ndk-gdb that is included in the Android NDK SDK will provide all the necessary debugging, and all it really needs is a wrapper to work with Visual Studio. Alas, I have started writing a plugin in for Visual Studio to allow debugging C++ code for Android. You can check out the project below:

vs-android-debugger Google Code Project

Tags: , , , , , , , , ,

Android vs iOS

So, another one of those Android vs iOS rants. I personally have never liked Apple products, so take that for whatever it is worth. When you consider the positive points of Android against iOS there are a few things in favour for Apple products. First, there are a lot of applications and music available. Second, they have a larger install base which means that more companies are willing to target iOS devices for apps.

However, the biggest problem is that iOS is very much a smaller version of Mac OS X and Android is much more like Linux/Windows. It really comes down to the question, do you want to be restricted by your device or do you want the freedom to do what you want? Mac doesn’t let you do anything you want, at least not easily and iOS is no exception. Linux on the other hand lets you do anything you want, and Android is the little brother that tries to makes his parents proud. Now if you take a look at iOS for iPad vs Android for tablets you continue to see the same problems, iOS restricts and doesn’t let you do anything while Android is open and welcoming.

On iOS you have icons, and … well thats about it. On Android you have icons, widgets, live icons, live wallpapers, etc. Android tablets have a true tablet OS where iPads have the same OS that iPhones and iPod touches do, not really adapted to take full use of the larger screen. Android has true multi-tasking, while iOS sorta fakes it.

Now, with the announcement for the Amazon Kindle Fire at $199 I think Android is about to get a huge boost. Not to mention that the Motorola Xoom has a family edition coming out soon for $379. All the while the iPad will continue to be sold at $500.

Does Android have its problems? Sure it does, but so does iOS. Is one absolutely better than the other? No, because it would be insane to say so. However, my personal preference is to have a device that actually works with the web, instead of require that the web adapt to it. While I may not be the biggest fan of flash, it still is an important part of the internet.

Tags: , , , , , , , , , , ,

WPtouch

For the first time today I used the mobile version of the site. I gotta say, quite awesome. I’d never been able to check it out before today, but I’m glad that it’s been available all this time. I guess you never really appreciate what your desktop can do until you use something else.

Evidently there is both a free and pro version (which you have to pay for). I’m not going to run down the different options available, but I encourage you to check it out (if you have a Wordpress blog)

WPtouch

Tags: , ,

Limbo

Well yesterday Limbo came out on XBLA. This game is definitely different, and interesting for sure. However, this game is not without it’s problems. First, the stylization is great… maybe a little too dark overall, but still a great concept and they pulled it off. The sound effects fix perfectly. However, there are no instructions, or music. There also seems to be absolutely no story, which I was a little disappointed by. One thing that you definitely need is patience for this game. There is a lot of trail and error, due to the lack of explanation. One great thing is the fact that there is almost no punishment for failing. When you die, you are almost right back where you were. I’ve been able to get through half the game in probably ~3 hours (including all my trail and error). This game really reminds me of Braid, for a few reasons; 1 this is an indie game, 2 new style/innovation in the gameplay, 3 worth your money. I don’t really think that this game will have any lasting replay value, but it doesn’t matter to me. If you want something to entertain you for a while, check out Limbo – available now on XBLA

Tags: , , ,

Digital Identity

In today’s day digital age, your online identity is increasingly becoming as important as your physical identity. If you don’t realize how true this statement is, take a moment and think about how many places online you enter a username and password, rather than your given name. Because of the power of Google, there is going to be a very extensive history of everything you’ve done online, with respects to places that you have signed up for an account and places where you have posted your.

Now, proceed with caution… you may not like the results. If you really want to see an extensive history on your online activities, simply head to your nearest search engine (Google) and type in your username, and hit search. Now, you can see quite a vast history. And if you have posted comments in the past, then take a read over them… they may be amusing. I did a simple Google search on my given name, and it yielded quite a number of results (not all of them actually applied to me, but there were still quite a few). Then I did a Google search of my online username that I use everywhere, and the difference between the two was staggering.

I recently enlightened a colleague to this fact, and the reaction on his face when he saw his online history was quite amusing. What does your history look like?

Tags: , , , ,

ImgBurn

Have you ever had a disc image that you needed to burn. Do you not need all the fancy bells and whistles that commercial products have. Do you want something simple, effective, and free? Well if thats the case then you need to use ImgBurn. Simply head on over to the ImgBurn Website and download this awesome piece of software. It is just so great, I don’t think I’ll need another image to disc writing software again!

Tags: , , , ,