Button into tab

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Button into tab

Postby Dayn » Tue Jul 28, 2009 4:28 pm

Hi

I try to add buttons into a tab, but when I run my code. there are en error in android emulator.

I think my xml file is wrong because it's designed it out of (height and width) tab but I don't find how to add that into a tab without error.

my code :

package m.dany.anrdoid.inertfacegraphiquevvm;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class InerfaceGraphiqueVVM extends TabActivity {

Button supprimer;
Button repondre;

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

setContentView(R.layout.tab);

final TabHost oTabHost = getTabHost();

TabSpec ts1 = oTabHost.newTabSpec("tab1");
ts1.setIndicator("Voicemail");
ts1.setContent(new Intent(this, Tab1.class));
oTabHost.addTab(ts1);

TabSpec ts2 = oTabHost.newTabSpec("tab2");
ts2.setIndicator("TAB 2");
ts2.setContent(R.id.textview2);
oTabHost.addTab(ts2);

TabSpec ts3 = oTabHost.newTabSpec("tab3");
ts3.setIndicator("TAB 3");
ts3.setContent(R.id.textview3);
oTabHost.addTab(ts3);

// 4ème onglet en option voir fichier XML aussi
/* TabSpec ts4 = oTabHost.newTabSpec("tab4");
ts4.setIndicator("TAB 4");
ts4.setContent(R.id.textview4);
oTabHost.addTab(ts4);
*/

oTabHost.setCurrentTab(0);

}
}


the xml file fot tab and following by xml file for button :


here:

<?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">
<TextView
android:id="@+id/textview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:id="@+id/textview2"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<TextView
android:id="@+id/textview3"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />

<!-- 4ème onglet en option -->
<!-- <TextView
android:id="@+id/textview4"
android:layout_width="fill_parent"
android:layout_height="fill_parent" /> -->

</FrameLayout>
</LinearLayout>
</TabHost>





and here:


<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:id="@+id/widget235"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<Button
android:id="@+id/supprimer"
android:layout_width="100px"
android:layout_height="40px"
android:text="Supprimer"
android:textStyle="bold"
android:layout_x="180px"
android:layout_y="349px"
>
</Button>
<Button
android:id="@+id/repondre"
android:layout_width="100px"
android:layout_height="40px"
android:text="Répondre"
android:textStyle="bold"
android:layout_x="42px"
android:layout_y="349px"
>
</Button>
</AbsoluteLayout>

I'm really blocked so what the matter ?? please !

Thanks
Attachments
bouton.JPG
bouton.JPG (32.92 KiB) Viewed 240 times
User avatar
Dayn
Developer
Developer
 
Posts: 31
Joined: Thu Jul 09, 2009 10:45 am
Location: Paris and Dijon

Top

FIX it now

Postby Dayn » Thu Jul 30, 2009 9:21 am

Hi so my issue is so simple

error:

>
> 07-29 15:19:16.878: ERROR/AndroidRuntime(1633):
> java.lang.RuntimeException: Unable to start activity
> ComponentInfo{m.dany.anrdoid.inertfacegraphiquevvm/m.dany.anrdoid.inertfacegraphiquevvm.InerfaceGraphiqueVVM}:
> android.content.ActivityNotFoundException: Unable to find explicit
> activity class
> {m.dany.anrdoid.inertfacegraphiquevvm/m.dany.anrdoid.inertfacegraphiquevvm.Tab1};
> have you declared this activity in your AndroidManifest.xml?
>
> That seems fairly self-explanatory. Have you declared this activity in
> your AndroidManifest.xml?

so I add my new activity in my AndroidManifest.xml

like this :



<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="m.dany.anrdoid.inertfacegraphiquevvm"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">

<activity android:name=".InerfaceGraphiqueVVM"
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=".Tab1" android:label="Voicemail">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.SAMPLE_CODE"/>
</intent-filter>
</activity>



</application>
<uses-sdk android:minSdkVersion="3" />
</manifest>
User avatar
Dayn
Developer
Developer
 
Posts: 31
Joined: Thu Jul 09, 2009 10:45 am
Location: Paris and Dijon

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 5 guests