Il y a une erreur alors que je suis en train intention comme spec.setContent(Intent);
sur tabSpace, et il fonctionne très bien si je mets une disposition sur spec.setContent(tab1);
Erreur lors spec.setContent (intention) sur tabSpace
Et suivant est l'erreur: -
did you forget to call 'public void setup(localactivitymanager activitygroup)
Voici la classe: -
public class test extends AppCompatActivity {
Point size;
RelativeLayout r1;
CallbackManager callbackManager;
Context context;
TabHost.TabSpec spec_signin,spec_signup;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
context = getApplicationContext();
Display display = getWindowManager().getDefaultDisplay();
size = new Point();
display.getSize(size);
Bitmap bmp = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(
getResources(),R.drawable.accont_bannre),size.x,size.y,true);
Drawable dr = new BitmapDrawable(bmp);
r1 = (RelativeLayout)findViewById(R.id.r1);
r1.setBackgroundDrawable(dr);
TabHost host = (TabHost)this.findViewById(R.id.tabhost);
host.setup();
//Tab 1
spec_signin = host.newTabSpec("SIGNIN");
Intent songsIntent = new Intent(this, NotificationActivity.class);
spec_signin.setContent(songsIntent);
spec_signin.setIndicator("SIGN IN", getResources().getDrawable(R.drawable.active_arrow));
// spec_signin.setIndicator("SIGNIN");
host.addTab(spec_signin);
//Tab 2
spec_signup = host.newTabSpec("SIGNUP");
Intent Intent = new Intent(this, NotificationActivity.class);
spec_signup.setContent(Intent);
spec_signup.setIndicator("SIGN UP", getResources().getDrawable(R.drawable.active_arrow));
// spec_signup.setIndicator("SIGNUP");
host.addTab(spec_signup);
}//oncreate ends
}
et le XML: - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TabHost android:id="@+id/tabhost" android:layout_width="fill_parent" android:layout_height="wrap_content"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/r2"> <RelativeLayout android:id="@+id/r1" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="270dp"> <LinearLayout android:layout_alignParentBottom="true" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> <View android:layout_above="@+id/tabs" android:id="@+id/v1" android:layout_width="match_parent" android:layout_height="1dp" android:background="#ccc7c7"/> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout> </RelativeLayout> <FrameLayout android:background="#dede" android:layout_below="@+id/r1" android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="match_parent"> </FrameLayout> </RelativeLayout> </TabHost> </RelativeLayout>
`