activity_main.xml
=============
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TabHost
android1:id="@android:id/tabhost"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android1:layout_alignParentLeft="true"
android1:layout_alignParentTop="true" >
<LinearLayout
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android1:orientation="vertical" >
<TabWidget
android1:id="@android:id/tabs"
android1:layout_width="match_parent"
android1:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android1:id="@android:id/tabcontent"
android1:layout_width="match_parent"
android1:layout_height="match_parent" >
<LinearLayout
android1:id="@+id/tab1"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/one"
/>
</LinearLayout>
<LinearLayout
android1:id="@+id/tab2"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/three"
/>
</LinearLayout>
<LinearLayout
android1:id="@+id/tab3"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
help.xml
----------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/two"
/>
</LinearLayout>
ActivityMain.java
==============
package com.kundan.tabhost;
import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TabHost;
@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
TabHost tabs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tabs=(TabHost) findViewById(android.R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec("tag1");
spec.setContent(R.id.tab1);
spec.setIndicator("img1");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag2");
spec.setContent(R.id.tab2);
spec.setIndicator("img2");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag3");
spec.setContent(R.id.tab3);
spec.setIndicator("img3");
Intent i=new Intent(this,Help.class);
spec.setContent(i);
tabs.addTab(spec);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Help.java
------------
package com.kundan.tabhost;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
public class Help extends Activity{
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
iv=(ImageView) findViewById(R.id.imageView1);
iv.setScaleType(ScaleType.CENTER_INSIDE);
}
}
=============
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android1="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<TabHost
android1:id="@android:id/tabhost"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android1:layout_alignParentLeft="true"
android1:layout_alignParentTop="true" >
<LinearLayout
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android1:orientation="vertical" >
<TabWidget
android1:id="@android:id/tabs"
android1:layout_width="match_parent"
android1:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android1:id="@android:id/tabcontent"
android1:layout_width="match_parent"
android1:layout_height="match_parent" >
<LinearLayout
android1:id="@+id/tab1"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/one"
/>
</LinearLayout>
<LinearLayout
android1:id="@+id/tab2"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/three"
/>
</LinearLayout>
<LinearLayout
android1:id="@+id/tab3"
android1:layout_width="match_parent"
android1:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</RelativeLayout>
help.xml
----------
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/two"
/>
</LinearLayout>
ActivityMain.java
==============
package com.kundan.tabhost;
import android.os.Bundle;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.view.Menu;
import android.widget.TabHost;
@SuppressWarnings("deprecation")
public class MainActivity extends TabActivity {
TabHost tabs;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tabs=(TabHost) findViewById(android.R.id.tabhost);
tabs.setup();
TabHost.TabSpec spec=tabs.newTabSpec("tag1");
spec.setContent(R.id.tab1);
spec.setIndicator("img1");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag2");
spec.setContent(R.id.tab2);
spec.setIndicator("img2");
tabs.addTab(spec);
spec=tabs.newTabSpec("tag3");
spec.setContent(R.id.tab3);
spec.setIndicator("img3");
Intent i=new Intent(this,Help.class);
spec.setContent(i);
tabs.addTab(spec);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Help.java
------------
package com.kundan.tabhost;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
public class Help extends Activity{
ImageView iv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.help);
iv=(ImageView) findViewById(R.id.imageView1);
iv.setScaleType(ScaleType.CENTER_INSIDE);
}
}
No comments:
Post a Comment