Changes from the example:
1. Create new classes for all activities: AlbumsActivity, ArtistsActivity, and SongsActivity (note you will have 3 additional .java files for these.
Add the onCreate method for each of the activities so when they are instantiated the UI tab does something so you can see it at work.
examples:
AlbumsActivity.java
package com.hhicg.hellotabwidget;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class AlbumsActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Albums tab");
setContentView(textview);
}
}
ArtistsActivity.java
package com.hhicg.hellotabwidget;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class ArtistsActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Artists tab");
setContentView(textview);
}
}
package com.hhicg.hellotabwidget;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class SongsActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is the Songs tab");
setContentView(textview);
}
}
3. For each activity there must be an entry in the manifest. ie for the AndroidManifest.xml
4. In Eclipse you will need to create a new folder drawable to contain the referenced images and the ic_tab_artist.xml.
5. The Main.xml should be the same the example although the layout does not render properly in the ide..
6. This is what my ide looks like
This is the second example Ive tried using java, android and eclipse.. hopefully it saves you all some time.
No comments:
Post a Comment