Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old July 13th, 2010, 03:05 PM   #1 (permalink)
Junior Member
 
Join Date: Jul 2010
Posts: 17
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Cry New to Android and already stuck with the Tab Tutorial...

Hi there, I am very new to Android and I have been working through various tutorials, so far everything's been fine until I started with the Android Tab Tutorial. I still have the "force close" error, even though I have tried several solutions that I found on the web. If someone could help me find where I am have done something wrong in my code, that would be absolutely fantastic. I am really getting desperate.

So here is what I have done and thank you so much in advance...

My [edited] Manifest.xml:

Code:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mobilevideoeditor.moved"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
          <activity android:name=".ShareGalleryView" android:label="@string/app_name"
                      android:theme="@android:style/Theme.NoTitleBar"> </activity> 
                      <activity android:name=".EditGalleryView" android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar"> </activity>  
           <activity android:name=".GalleryView" android:label="@string/app_name"
                  android:theme="@android:style/Theme.NoTitleBar">   
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <activity>
        

    </application>


</manifest>
The main.xml:

Code:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp">
        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:padding="5dp" />
    </LinearLayout>
</TabHost>
The ic_tab_share.xml and ic_tab_edit.xml:

Code:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- When selected, use ic_tab_share (grey icon) -->
    <item android:drawable="@drawable/ic_tab_share"
          android:state_selected="true" />
    <!-- When not selected, use ic_tab_share_unselected (white icon)-->
    <item android:drawable="@drawable/ic_tab_share_unselected" />
</selector>
The GalleryView.java file:

Code:
package com.mobilevideoeditor.moved;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;

public class GalleryView extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Reusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, EditGalleryView.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("edit").setIndicator("Edit",
                          res.getDrawable(R.drawable.ic_tab_edit))
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, ShareGalleryView.class);
        spec = tabHost.newTabSpec("share").setIndicator("Share",
                          res.getDrawable(R.drawable.ic_tab_share))
                          .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);
    }
}
and finally the ShareGalleryView.java and the EditGalleryView.java:

Code:
package com.mobilevideoeditor.moved;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;


public class EditGalleryView extends Activity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        TextView textview = new TextView(this);
        textview.setText("This is the Edit tab!");
        setContentView(textview);
    }
}

kivy is offline  
Last edited by kivy; July 13th, 2010 at 06:25 PM. Reason: PROBLEM SOLVED
Reply With Quote
Sponsors
Old July 13th, 2010, 03:27 PM   #2 (permalink)
Member
 
Join Date: Sep 2009
Location: Birmingham, UK
Posts: 148
 
Device(s): G1 (Developer model), HTC Tattoo, Nexus One.
Thanks: 1
Thanked 26 Times in 22 Posts
Default

Hi kivy,

Quote:
Originally Posted by kivy View Post
If someone could help me find where I am have done something wrong in my code, that would be absolutely fantastic. I am really getting desperate.
There are 2 ways to start to investigate the problem, and they are well worth becoming familiar with.

The first and simplest is to look at the logging output. That will give you an error message and stack trace which will tell you where it crashed. Quite often the cause will be obvious once you focus in the right area.

If the logging isn't enough then the debugger can be a big help. You can step through the code until it crashes, examining variables as you go. Or if you know roughly where it crashes then you can set a breakpoint which will stop the program in the debugger.

If you're still stumped after that then the log output will be useful as you can post it here, and it will help others to help you solve the problem.

If you need pointers on how to look at the log output, and how to get started with the debugger then just ask.

Mark
markb is offline  
Reply With Quote
Old July 13th, 2010, 03:44 PM   #3 (permalink)
Junior Member
 
Join Date: Jul 2010
Posts: 17
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default

First of all I found what I did wrong

Quote:
Originally Posted by markb View Post

If you need pointers on how to look at the log output, and how to get started with the debugger then just ask.

Mark
I just looked at it I could understand some of it but I am not really comfortable with the debugger yet... but I think I'll get to it, thanks
kivy is offline  
Reply With Quote
Old July 13th, 2010, 06:27 PM   #4 (permalink)
cp1
Member
 
Join Date: Apr 2010
Posts: 328
 
Device(s):
Thanks: 12
Thanked 29 Times in 25 Posts
Default

Definitely check the logcat output in DDMS. It will tell you exactly what line your program crashed on.
cp1 is offline  
Reply With Quote
Old July 13th, 2010, 07:13 PM   #5 (permalink)
Junior Member
 
Join Date: Jul 2010
Posts: 22
 
Device(s): ....X....
Thanks: 4
Thanked 0 Times in 0 Posts
Default

Just wondering if you fixed it by adding the ShareGalleryView and the EditGalleryView activities to the manifest xml file?

I had this same problem two days ago and found some suggestions on stack overflow, and adding the activity for each tab to the xml fixed it.

Code:
<activity android:name=".AlbumsActivity"  android:label="@string/app_name"></activity>
<activity android:name=".ArtistsActivity"  android:label="@string/app_name"></activity>
<activity android:name=".SongsActivity"  android:label="@string/app_name"></activity>
cam4mav is offline  
Reply With Quote
Old July 13th, 2010, 07:57 PM   #6 (permalink)
Junior Member
 
Join Date: Jul 2010
Posts: 17
 
Device(s):
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Quote:
Just wondering if you fixed it by adding the ShareGalleryView and the EditGalleryView activities to the manifest xml file?

I had this same problem two days ago and found some suggestions on stack overflow, and adding the activity for each tab to the xml fixed it.
No, I already had them in the manifest xml file, my problem was that I inserted them at the wrong location within the file.
kivy is offline  
Reply With Quote
Old February 10th, 2011, 09:32 AM   #7 (permalink)
New Member
 
Join Date: Feb 2011
Posts: 1
 
Device(s):
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i hav same prblm....pls help ..
nikhilkilivayi is offline  
Reply With Quote
Reply

Bookmarks

Tags
problem, tabs, tutorial


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Android Game Development Tutorial marzec Application Development 15 January 16th, 2012 08:20 AM
Android Video Tutorial Series MotoDroidHelpandInfo Developer 101 0 November 14th, 2010 12:44 AM
Tutorial: Android Sync App openmobster Developer 101 0 November 13th, 2010 02:14 PM
Android custom bootscreens tutorial. WACOMalt Android Themes 0 August 5th, 2010 10:14 PM
Android MapView Tutorial garethcwilliams Android Applications 1 March 8th, 2010 10:47 AM



All times are GMT -5. The time now is 11:30 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo