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

Anybody can explain,,,wat is wrong in the code,,its not working

kiranuday43

Newbie
Mar 3, 2010
20
0
in creating tablayout

I created all the tabs ic_tab-albums etc,,..but still not working and want to place a button in albumsactivity:thinking:

Tab Layout | Android Developers


package com.android.Tablayout;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class AlbumsActivity extends Activity{
//private Button tv;

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//showSplashScreen();
showStartButton();
}
private void showStartButton()
{
//Button mybit=new Button(this);
final Button mybit = (Button) findViewById(R.id.my_bit);

// mybit.setText("albums lists");
//tv.setMaxHeight(10);
//tv.setHeight(2);
//tv.setWidth(5);
// mybit.setTextSize(40);
//tv.setBackgroundColor(BIND_AUTO_CREATE);
mybit.setGravity(Gravity.RIGHT);



mybit.setOnClickListener(new OnClickListener() {
//@Override
public void onClick(View v) {
boolean tv=true;
tv=false;
//finish();
}
});
setContentView(R.id.my_bit);
}


}



in main.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">
<LinearLayout
android:eek:rientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<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"
android:padding="5dp" />
<Button android:id="@+id/my_bit"
android:layout_width="125px" android:layout_height="50px"
android:background="#FF222222" />

</LinearLayout>
</TabHost>
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones