0

I have a tabHost with 2 Tabs, Details and Attachments. What I want to do is, when I press the Attachments Tab, I want to hide Information that is in a RelativeLayout. I know I have to setVisibility(View.VISIBLE) but how can I associate this method with that Tab ?

I have this code to create my Tab:

intent = new Intent();
    intent.putExtras(bundle);
    spec = tabHost.newTabSpec("Attachments")
             .setIndicator("Attachments")  
                .setContent(intent
                  .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    tabHost.addTab(spec);   

Can anyone help me please ?

Thanks.

Akash
  • 367
  • 9
  • 21

1 Answers1

0

You can send messages by broadcast intent.

  1. set broadcast receiver on your activity that will receive message
  2. send broadcast intent when needed.

Here are code snippet.

@Override
protected void onResume() {
  super.onResume();
  if( listener != null) {
    registerReceiver(listener, new  IntentFilter( "hide_me"));
  }
}

@Override
protected void onPause() {
  super.onPause();
  if( listener != null) {
    unregisterReceiver(listener);
  }
}

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  listener = new BroadcastReceiver() { //put your code here 
  }
}

and send message like this:

Intent i = new Intent();
i.setAction("hide_me");
sendBroadcast(i);
kingori
  • 2,406
  • 27
  • 30