Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:58:18+00:00 2026-06-16T00:58:18+00:00

In my android app i am tring to implement tabhost. Actually i am trying

  • 0

In my android app i am tring to implement tabhost.
Actually i am trying udapt tutorial from androidhive
However i am continuously getting fatal error.
Help me please fix this error

public class AndroidTabAndListView extends TabActivity {
    // TabSpec Names
    private static final String INBOX_SPEC = "Inbox";
    private static final String OUTBOX_SPEC = "Outbox";
    private static final String PROFILE_SPEC = "Profile";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TabHost tabHost = getTabHost();


        TabSpec inboxSpec = tabHost.newTabSpec(INBOX_SPEC);

        inboxSpec.setIndicator(INBOX_SPEC, getResources().getDrawable(R.drawable.icon_inbox));
        Intent inboxIntent = new Intent(this, InboxActivity.class);

        inboxSpec.setContent(inboxIntent);


        TabSpec outboxSpec = tabHost.newTabSpec(OUTBOX_SPEC);
        outboxSpec.setIndicator(OUTBOX_SPEC, getResources().getDrawable(R.drawable.icon_outbox));
        Intent outboxIntent = new Intent(this, OutboxActivity.class);
        outboxSpec.setContent(outboxIntent);


        TabSpec profileSpec = tabHost.newTabSpec(PROFILE_SPEC);
        profileSpec.setIndicator(PROFILE_SPEC, getResources().getDrawable(R.drawable.icon_profile));
        Intent profileIntent = new Intent(this, Testactivity.class);
        profileSpec.setContent(profileIntent);



        tabHost.addTab(inboxSpec); 
        tabHost.addTab(outboxSpec);
        tabHost.addTab(profileSpec);

    }
}

layout

<?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">
        <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"/>
    </LinearLayout>
</TabHost>

adapter

public class CandidateAdapter extends BaseAdapter{
    Context ctx;
    LayoutInflater lInflater;
    ArrayList<Candidate> objects;
    CandidateAdapter(Context context, ArrayList<Candidate> candidates) {
            ctx = context;
            objects = candidates;
            lInflater = (LayoutInflater) ctx
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          }
    public int getCount() {
        return objects.size();
      }
    public Object getItem(int position) {
        return objects.get(position);
      }
    public long getItemId(int position) {
        return position;
      }
    Candidate getCandidate(int position) {
        return ((Candidate) getItem(position));
      }
    public View getView(int position, View convertView, ViewGroup parent) {
        // используем созданные, но не используемые view
        View view = convertView;
        if (view == null) {
          view = lInflater.inflate(R.layout.inbox_list_item, parent, false);
        }
        Candidate p = getCandidate(position);
        ((TextView) view.findViewById(R.id.from)).setText(p.get_name());
        ((TextView) view.findViewById(R.id.subject)).setText(p.get_office());
        return view;
    }



}

activity

public class InboxActivity extends ListActivity {

    List<Candidate> candidates;
    private DatabaseHandler db;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.inbox_list);
        db = new DatabaseHandler(this);
        candidates = db.getAllCandidates(1);
        CandidateAdapter adapter = new CandidateAdapter(this,(ArrayList) candidates);
        ListView lvMain = (ListView) findViewById(R.id.lvMain);
        lvMain.setAdapter(adapter);

    }



}

layout for activity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/lvMain"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

list item layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <!-- From Label -->
    <TextView
        android:id="@+id/from"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:paddingTop="8dip"
        android:paddingLeft="8dip"
        android:paddingBottom="4dip"
        android:textSize="20dip"
        android:textStyle="bold" />

    <!-- Mail Subject -->
    <TextView android:id="@+id/subject"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:paddingLeft="8dip"
        android:paddingBottom="6dip"
        android:textSize="15dip"
        android:layout_below="@id/from"/>

    <!-- Mail date -->
    <TextView android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:padding="8dip"/>

</RelativeLayout>

other activities are actually the same
only fields:

setContentView(R.layout.inbox_list); candidates =
db.getAllCandidates(1);

are different

logcat output

12-15 23:27:47.529: W/dalvikvm(397): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
12-15 23:27:47.568: E/AndroidRuntime(397): FATAL EXCEPTION: main
12-15 23:27:47.568: E/AndroidRuntime(397): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.s1042512.newvoter/com.s1042512.newvoter.AndroidTabAndListView}: java.lang.ClassNotFoundException: com.s1042512.newvoter.AndroidTabAndListView in loader dalvik.system.PathClassLoader[/data/app/com.s1042512.newvoter-2.apk]
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.os.Looper.loop(Looper.java:123)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.ActivityThread.main(ActivityThread.java:4627)
12-15 23:27:47.568: E/AndroidRuntime(397):  at java.lang.reflect.Method.invokeNative(Native Method)
12-15 23:27:47.568: E/AndroidRuntime(397):  at java.lang.reflect.Method.invoke(Method.java:521)
12-15 23:27:47.568: E/AndroidRuntime(397):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
12-15 23:27:47.568: E/AndroidRuntime(397):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
12-15 23:27:47.568: E/AndroidRuntime(397):  at dalvik.system.NativeStart.main(Native Method)
12-15 23:27:47.568: E/AndroidRuntime(397): Caused by: java.lang.ClassNotFoundException: com.s1042512.newvoter.AndroidTabAndListView in loader dalvik.system.PathClassLoader[/data/app/com.s1042512.newvoter-2.apk]
12-15 23:27:47.568: E/AndroidRuntime(397):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
12-15 23:27:47.568: E/AndroidRuntime(397):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
12-15 23:27:47.568: E/AndroidRuntime(397):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
12-15 23:27:47.568: E/AndroidRuntime(397):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
12-15 23:27:47.568: E/AndroidRuntime(397):  ... 11 more
12-15 23:27:55.818: I/Process(397): Sending signal. PID: 397 SIG: 9
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:58:20+00:00Added an answer on June 16, 2026 at 12:58 am

    You have a problem with your package names, make sure that all your classes and your Android Manifest reference the same package name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement the Tumblr API in an Android app. I'm really getting
I am trying to implement ViewHolder in my Android app, but I keep getting
I have been trying to implement an upgrade plan for my Android app which
I'm trying to implement an Android app that needs to alarm (or to alert)
I'm trying to implement a splash screen for my webview android app, so that
I am trying to implement AUTOUPDATE functionality in my android app, as it is
I'm trying to implement the Facebook SDK (3.0 beta) in an Android app that
So i'm trying to implement that into my app, however the problem is that
I am trying to implement a Codeigniter based app on Android via phonegap, all
I am trying to implement this example http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html and i have followed exactly all

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.