• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps |Help|About my source code (Tab Android)

hello guys, I'm newbie as an android programmer, Actually I have problem in my source code when I'm trying to make an application.. I'm trying to show Tab model after a button clicked. but the result is not respond..:( please help me..here is the source code :)

mainkubus.xml
<?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">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/mainkubus"
android:text="@string/mainkubus"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</FrameLayout>
</TabHost>

mainkubus.java
package org.example.hello;

import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.content.Intent;


public class mainkubus extends TabActivity implements TabHost.TabContentFactory{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final TabHost tabHost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.mainkubus, tabHost.getTabContentView(),true);

tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("intent")
.setContent(new Intent(this, mainkubus.class)));

tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("intent")
.setContent(new Intent(this, mainkubus1.class)));

tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("destroy")
.setContent(new Intent(this, mainkubus2.class)
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

tabHost.addTab(tabHost.newTabSpec("tab4")
.setIndicator("factory",
getResources().getDrawable(R.drawable.icon))
.setContent(this));

}

public View createTabContent(String tag) {
final TextView tv = new TextView(this);
tv.setText("Content for tab with tag " + tag);
return tv;
}

}

activity in AndroidManifest
<activity android:name=".mainkubus" android:label="@string/mainkubus_title"></activity>


Picture
it is the view of button
attachment.php


but after click a button, it doesn't work
attachment.php

Actually I use Android 2-2 Emulator and Eclipse java Helios 32 bit on Windows 7
 

Attachments

  • g1.jpg
    g1.jpg
    34.6 KB · Views: 140
  • g2.jpg
    g2.jpg
    32.5 KB · Views: 138
You need to familiarize yourself with the debugger and see what kind of error is actually occurring... I'm not the best person to ask about that since I'm still having a lot of problems myself, but try setting a breakpoint at the first instruction, then stepping over each instruction. Once the error occurs you'll probably get a file not available error in the Android classes (at least that's what I'm getting instead of the stack trace that others are reporting), but the local variables on the top right will somewhere include something like "Null Pointer Exception" or something like that. That should help you pinpoint the problem.
 
Back
Top Bottom