Hi friends,
I'm making Customizable android Tab's,and it works fine without adding " 
Intent " but when I set the intent it 
I didn't understand where I'm making mistake ..

Here is codes , or check this pastebin link >>> http://pastebin.com/yeEP0rwH

....
public class CustomTabActivity extends Activity {

    private TabHost mTabHost;
    private void setupTabHost() {
        mTabHost = (TabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup();
    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // construct the tabhost
        setContentView(R.layout.main);

        setupTabHost();
        mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

        setupTab(new TextView(this), "Home",new 
Intent(this,HomeTabActivity.class));
    }

    private void setupTab(final View view, final String tag, final Intent 
intent) {
        View tabview = createTabView(mTabHost.getContext(), tag);

        TabSpec setContent = 
mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);
        mTabHost.addTab(setContent);

    }

    private static View createTabView(final Context context, final String 
text) {
        View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, 
null);
        TextView tv = (TextView) view.findViewById(R.id.tabsText);
        tv.setText(text);
        return view;
    }
}

>HomeTabActivity.java
...
 public class HomeTabActivity extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.testlayout);
    }
}


layout/testlayout.xml

<?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" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hola,I'm going here...."
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout> 

>>Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android";
    package="com.testroid.android.tabs" android:versionCode="1"
    android:versionName="1.0.0">
    <uses-sdk android:minSdkVersion="4" />

    <application android:icon="@drawable/icon"
        android:label="@string/app_name" android:debuggable="false">
        <activity android:name=".CustomTabActivity"
            android:configChanges="orientation" 
android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".HomeTabActivity"
              android:label="@string/app_name">
        </activity>
    </application>    
</manifest> 


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to