[android-developers] Opening a new window from within tabhost

2011-11-02 Thread Ashley Waters
Hey im developing my first proper app for android and have run into 2
small hickups and was hoping for some help basicaly the main problem
is that i cant seem to change to a new view from within tabhost. I
have 4 tabs 2 just show a simple xml file the 3rd shows a series of
pictures which i want to make clickable so that they expand out into
player bio's. atm im attempting to do this in the following way but it
just causes my application to crash

package com.BPRUFC;

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

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

TabHost mTabHost = getTabHost();

 
mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("Fixtures").setContent(R.id.fixtures));
 
mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Results").setContent(R.id.results));
 
mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("Players").setContent(R.id.bio));
 
mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("Tour").setContent(R.id.tour));

mTabHost.setCurrentTab(0);

int days = 184;
String tour2 = getString(R.string.tour, days);
}

public void clicked(View view)
{
Intent myIntent = new Intent(BPRUFCAppActivity.this,
PlayerBio.class);
BPRUFCAppActivity.this.startActivity(myIntent);
}
}

main Xml stopped after first pic as its quite long


http://schemas.android.com/apk/res/android";
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">












Thanks in advance and im sure its a noob mistake

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


Re: [android-developers] Opening a new window from within tabhost

2011-11-03 Thread frank he
try  xxx.this.getParent.startActivity
在 2011-11-3 上午6:46,"Ashley Waters" 写道:

> Hey im developing my first proper app for android and have run into 2
> small hickups and was hoping for some help basicaly the main problem
> is that i cant seem to change to a new view from within tabhost. I
> have 4 tabs 2 just show a simple xml file the 3rd shows a series of
> pictures which i want to make clickable so that they expand out into
> player bio's. atm im attempting to do this in the following way but it
> just causes my application to crash
>
> package com.BPRUFC;
>
> import android.app.TabActivity;
> import android.content.Intent;
> import android.os.Bundle;
> import android.view.View;
> import android.widget.TabHost;
>
> public class BPRUFCAppActivity extends TabActivity {
>/** Called when the activity is first created. */
>@Override
>public void onCreate(Bundle savedInstanceState) {
>super.onCreate(savedInstanceState);
>setContentView(R.layout.main);
>
>TabHost mTabHost = getTabHost();
>
>
>
> mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("Fixtures").setContent(R.id.fixtures));
>
>
> mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("Results").setContent(R.id.results));
>
>
> mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("Players").setContent(R.id.bio));
>
>
> mTabHost.addTab(mTabHost.newTabSpec("tab_test4").setIndicator("Tour").setContent(R.id.tour));
>
>mTabHost.setCurrentTab(0);
>
>int days = 184;
>String tour2 = getString(R.string.tour, days);
>}
>
>public void clicked(View view)
>{
>Intent myIntent = new Intent(BPRUFCAppActivity.this,
> PlayerBio.class);
>BPRUFCAppActivity.this.startActivity(myIntent);
>}
> }
>
> main Xml stopped after first pic as its quite long
>
> 
> http://schemas.android.com/apk/res/android";
>android:id="@android:id/tabhost"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent">
>android:orientation="vertical"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent">
>android:id="@android:id/tabs"
>android:layout_width="fill_parent"
>android:layout_height="wrap_content" />
>android:id="@android:id/tabcontent"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent">
>android:id="@+id/ScrollView01"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent" >
>android:id="@+id/fixtures"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent"
>android:text="@string/fixtures" />
>
>android:id="@+id/results"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent"
>android:text="Results go here" />
>android:id="@+id/ScrollView02"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent">
>android:id="@+id/bio"
>android:layout_width="fill_parent"
>android:layout_height="fill_parent">
>android:layout_height="90dip"
>android:id="@+id/imageView1"
>android:src="@drawable/forrest"
>android:onClick="clicked"
>android:layout_alignParentTop="true"
>android:layout_alignParentLeft="true"
>android:layout_marginLeft="10dp"
>android:layout_marginTop="10dp">
>
>
> Thanks in advance and im sure its a noob mistake
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

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